Sourcecode::Spellchecker - Detects common misspellings in source code and suggests corrections.
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"; }
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;
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.
Sourcecode::Spellchecker
Returns a list of misspellings of the form:
( {line => 1, misspelling => 'sofware', correction => 'software'}, {line => 7, misspelling => 'speach', correction => 'speech'} )
spellcheck_source.pl - Checks a source file for common misspellings.
spellcheck_source.pl
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.
Zachary Blair, <zblair@cpan.org>
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.
To install Sourcecode::Spellchecker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sourcecode::Spellchecker
CPAN shell
perl -MCPAN -e shell install Sourcecode::Spellchecker
For more information on module installation, please visit the detailed CPAN module installation guide.