![]() |
![]()
| ![]() |
![]()
NAMEText::SpellChecker - OO interface for spell-checking a block of text SYNOPSISuse Text::SpellChecker; ($Text::SpellChecker::pre_hl_word, $Text::SpellChecker::post_hl_word) = (qw([ ])); my $checker = Text::SpellChecker->new(text => "Foor score and seven yeers ago"); while (my $word = $checker->next_word) { print $checker->highlighted_text, "\n", "$word : ", (join "\t", @{$checker->suggestions}), "\nChoose a new word : "; chomp (my $new_word = <STDIN>); $checker->replace(new_word => $new_word) if $new_word; } print "New text : ".$checker->text."\n"; --or-- use CGI; use Text::SpellChecker; my $q = new CGI; print $q->header, $q->start_html, $q->start_form(-method=>'POST',-action=>$ENV{SCRIPT_NAME}); my $checker = Text::SpellChecker->new( text => "Foor score and seven yeers ago", from_frozen => $q->param('frozen') # will be false the first time. ); $checker->replace(new_word => $q->param('replacement')) if $q->param('replace'); if (my $word = $checker->next_word) { print $q->p($checker->highlighted_text), $q->br, qq|Next word : "$word"|, $q->br, $q->submit(-name=>'replace',-value=>'replace with:'), $q->popup_menu(-name=>'replacement',-values=>$checker->suggestions), $q->submit(-name=>'skip'); } else { print "Done. New text : ".$checker->text; } print $q->hidden(-name => 'frozen', -value => $checker->serialize, -override => 1), $q->end_form, $q->end_html; DESCRIPTIONThis module is a thin layer above either Text::Aspell or Text::Hunspell (preferring the latter if available), and allows one to spellcheck a body of text. Whereas Text::(Hu|A)spell deals with words, Text::Spellchecker deals with blocks of text. For instance, we provide methods for iterating through the text, serializing the object (thus remembering where we left off), and highlighting the current misspelled word within the text. METHODS
CONFIGURATION OPTIONS
LICENSEThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. TODOAdd word to custom dictionary SEE ALSOText::Aspell, Text::Hunspell AUTHORBrian Duggan <bduggan@matatu.org>
|