NAME
Sourcecode::Spellchecker - Detects common misspellings in source code and suggests corrections.
SYNOPSIS
my
$checker
= new Sourcecode::Spellchecker;
my
$sourceFileName
=
'MySourceFile.cpp'
;
my
@results
=
$checker
->spellcheck(
$sourceFileName
);
if
(
@results
) {
foreach
my
$result
(
@results
) {
"$sourceFileName:$result->{line}: "
"'$result->{misspelling}' should be '$result->{correction}'\n"
;
}
}
else
{
"No spelling mistakes found.\n"
;
}
DESCRIPTION
This module scans a source file for common misspellings - including in comments, string literals, and identifier names - and suggests corrections.
For example, this module will find 'strat' (a misspelling of 'start') in the following lines:
my
$strat
;
const unsigned long STRAT_TIME = 0;
int
stratTime;
Dim TimeToStrat As Integer
const char* szMsg =
"It is time to strat."
;
// This is a comment indicating
when
we will strat
However, it will purposefully not find misspellings in the following lines because 'strat' is embedded in another word or split in two by a change in case:
std::string s = other.strAt(2);
Strategy strategy = Strategy.RunFast;
CONSTRUCTOR
new
my
$checker
= new Sourcecode::Spellchecker({
'hootdoog'
=>
'hotdog'
,
'hambergr'
=>
'hamburger'
});
Optionally takes a reference to a hash containing additional misspelling-spelling pairs to search for. If no argument is supplied, the default list of misspellings is used.
Returns a newly created Sourcecode::Spellchecker
object.
METHODS
spellcheck($filename)
Returns a list of misspellings of the form:
(
{
line
=> 1,
misspelling
=>
'sofware'
,
correction
=>
'software'
},
{
line
=> 7,
misspelling
=>
'speach'
,
correction
=>
'speech'
}
)
SEE ALSO
spellcheck_source.pl
- Checks a source file for common misspellings.
The list of common misspellings and corrections used by this module is primarily from Wikipedia's "List of commonly mispelled words" page at http://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings.
AUTHOR
Zachary Blair, <zblair@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2014 by Zachary D. Blair
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.