NAME
Sourcecode::Spellchecker - Basic detection of common misspellings in source code.
SYNOPSIS
use Sourcecode::Spellchecker
my $checker = new Sourcecode::Spellchecker;
my $sourceFileName = 'MySourceFile.cpp';
my @results = $checker->spellcheck($sourceFileName);
if (@results) {
foreach my $result (@results) {
print "$sourceFileName:$result->{line}: '$result->{misspelling}' " .
"should be '$result->{correction}'\n";
}
}
else {
print "No spelling mistakes found.\n";
}
DESCRIPTION
This module scans a source file, looking for common misspellings in the source, including in comments, string literals, and identifier names.
This module will therefore find 'strat' (a misspelling of 'start') in the following lines: my $strat; const unsigned long STRAT_TIME = 0; int stratTime; Dim TimeToStrat; const char* szMsg = "It is time to strat."; // This is a comment indicating when we will strat
However, it will purposefull not find a misspelling in the following lines even though the word 'strat' can be found in the line: std::string s = other.strAt(2); Strategy strategy = Strategy.RunFast;
CONSTRUCTOR
new
use Sourcecode::Spellchecker;
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) 2013 by Zachary 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.