|Think about Loose Coupling|
Lingua::Ispellby jeffa (Bishop)
|on Sep 13, 2000 at 08:22 UTC||Need Help??|
Item Description: Plug ispell easily into an application
Review Synopsis: Lightweight CPAN module for spell checking
(module written by John Porter)
This module simply encapsulates the Unix utility ispell, a text file spell checker that was first written by Ralph E. Gorin in 1971.
The GoodThe great thing about Lingua::Ispell is the ability to incorporate a fully functional spell checker into an application, great for finding spelling suggestions on any CGI search engine. You can specify a dictionary file for the module to use, on my system it defaulted to /usr/dict/words. You can also add words to the dictionary file and save it, all via the module's functions.
To use Lingua::Ispell, you simply use the module, and pass the text you wish to spell checker to the spellcheck function. This function will break the text up into words and return a list of hashes containing at least two keys, term and type. Term is the word being checked and type is one of six types the module uses to identify different possibilities. Out of these six types, I found only 2 of them to be usefull: miss and none. If the type is none, then the term is not found in the dictionary file and no corrections were found. If the type is miss, then an additional array that contains spelling corrections for that term is made available, named misses.
Example from the perldoc:
The BadYou have to specify where the ispell executable is located - not really bad, but it does affect the portability of you application - so keep this in mind when you have to move your app to another computer.
As a matter of fact, you will find that the above example probably will not work on your box without this line.
The Not So Ugly CodeHere is an example of Lingua::Ispell in action - a CGI form that allows the user to enter some text for spell checking. Remember to specify the location of ispell on your box.