Text::Ispell

Text::Ispell.pm is a Perl module for encapsulating access to the Ispell program.
Download

Text::Ispell Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • John Porter
  • Publisher web site:
  • http://search.cpan.org/~jdporter/Crypt-RandPasswd-0.02/lib/Crypt/RandPasswd.pm

Text::Ispell Tags


Text::Ispell Description

Text::Ispell.pm is a Perl module for encapsulating access to the Ispell program. Text::Ispell.pm is a Perl module for encapsulating access to the Ispell program.SYNOPSIS # Brief: use Text::Ispell; Text::Ispell::spellcheck( $string ); # or use Text::Ispell qw( spellcheck ); # import the function spellcheck( $string ); # Useful: use Text::Ispell qw( :all ); # import all symbols for my $r ( spellcheck( "hello hacking perl shrdlu 42" ) ) { print "$r->{'type'}: $r->{'term'}n"; }Text::Ispell::spellcheck() takes one argument. It must be a string, and it should contain only printable characters. One allowable exception is a terminal newline, which will be chomped off anyway. The line is fed to a coprocess running ispell for analysis. The line is parsed on non-wordchars into a sequence of terms. By default, the set of wordchars is defined in ispell as letters, digits, and the apostrophe. In other words, the line is subjected the equivalent of split /+/(ispell has a means to add characters to the default set, but currently Text::Ispell does not provide access to that feature.)The result of ispell's analysis of each term is a categorization of the term into one of six types: ok, root, miss, none, compound, and guess. Some of these carry additional information.Text::Ispell::spellcheck returns a list of objects, each corresponding to a term in the spellchecked string. Each object is a hash (hash-ref) with at least two entries: 'term' and 'type'. The former contains the term ispell is reporting on, and the latter is ispell's determination of that term's type (see above). For types 'ok' and 'none', that is all the information there is. For the type 'root', an additional hash entry is present: 'root'. Its value is the word which ispell identified in the dictionary as being the likely root of the current term. For the type 'miss', an additional hash entry is present: 'misses'. Its value is a string of words, comma-separated, which ispell identified as being "near-misses" of the current term, when scanning the dictionary.A quickie example: use Text::Ispell qw( spellcheck ); Text::Ispell::allow_compounds(1); for my $r ( spellcheck( "hello hacking perl salmoning fruithammer shrdlu 42" ) ) { if ( $r->{'type'} eq 'ok' ) { # as in the case of 'hello' print "'$r->{'term'}' was found in the dictionary.n"; } elsif ( $r->{'type'} eq 'root' ) { # as in the case of 'hacking' print "'$r->{'term'}' can be formed from root '$r->{'root'}'n"; } elsif ( $r->{'type'} eq 'miss' ) { # as in the case of 'perl' print "'$r->{'term'}' was not found in the dictionary;n"; print "Near misses: $r->{'misses'}n"; } elsif ( $r->{'type'} eq 'guess' ) { # as in the case of 'salmoning' print "'$r->{'term'}' was not found in the dictionary;n"; print "Root/affix Guesses: $r->{'guesses'}n"; } elsif ( $r->{'type'} eq 'compound' ) { # as in the case of 'fruithammer' print "'$r->{'term'}' is a valid compound word.n"; } elsif ( $r->{'type'} eq 'none' ) { # as in the case of 'shrdlu' print "No match for term '$r->{'term'}'n"; } # and numbers are skipped entirely, as in the case of 42. }Requirements:· Perl Requirements: · Perl


Text::Ispell Related Software