Text::SpellCheck - Uses the aspell binary to generate spellcheck info
use strict; use Text::SpellCheck; # I needed something that worked, that helped me implement the spellchecker for one of my websites, # and that didn't need a C compiler. This is it. In general, I'd say it's crap. It does work, # but the open2() -- aka open(FILE, "| aspell -a |") call is untested and probably fragile. # Nevertheless, to use it: my $sc = new Text::SpellCheck("/usr/bin/aspell"); my $result_hash = $sc->check_text(qq( I have mispeled some of thesee words for you. Can you guess wich ones? There are some <html_protections trvial=1> little regexps for html</html_protections> but I wouldn't depend on them too much. )); foreach my $word (keys %$result_hash) { print "$word was dumb: @{ $result_hash->{$word} }\n"; } This is handy: my $my_hightlit_text = $sc->html_highlight( q(<span style="background-color: yellow; color: red">), q(</span>), $some_curiously_spelled_text ); And so is this: use CGI; my $cgi = new CGI; my $my_hi = $sc->html_highlight( \&my_lighter, $text ); sub my_lighter { my $word = shift; # the word as it was written my $words = shift; # alternatives (arrayref) return $cgi->popup_menu({default=>"*$word*", values=>["*$word*", @$words]}); }
Jettero Heller jettero@cpan.org
http://www.voltar.org
perl(1)
To install Text::SpellCheck, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::SpellCheck
CPAN shell
perl -MCPAN -e shell install Text::SpellCheck
For more information on module installation, please visit the detailed CPAN module installation guide.