Using International Ispell
spell tool was a simple spelling checker
that compared the words of its input stream, one by one, to a master system
dictionary file (which was a sorted list of words in their correct spellings).
It would send to standard output all words from the input stream that were not
matched in the system dictionary.
spellwwb was an improvement on
spell, because it also compared its input against a
user's personal dictionary file. The WWB
spelladd tool was used to add words to the personal
dictionary. (Some UNIX
spell implementations later
added this "personal dictionary" facility.)
Today, several good spelling checkers for UNIX-based systems are available. One
of them, International Ispell, provides all the functionality of the old
spellwwb tool and gives a lot
more—it's a full-screen, interactive spelling checker, and it
currently supports 17 languages. You run it with the
ispell command; it takes the name of a file as an
argument. While even newer spelling checkers are now available, International
Ispell is a solid application, is actively supported, and is commonly available
on many UNIX systems today.
The simplest way to use
ispell is with GNU
spell, which is a wrapper for
ispell that provides the functionality of the old
spell tool. It reads input, checks each word
against the system dictionary as well as any (optional) personal dictionary, and
it outputs all misspelled words to standard output.
Try running it now, as shown in Listing 10.
Listing 10. The GNU spell wrapper in action
$ spell hello, world no typing mistakes here asdf asdf this is speld wrongg speld wrongg Ctrl-D $
To spell check a file with
spell, simply give the
file name as an argument. Use the
-n option to
precede any misspelled words by the line number in the file in which they occur.
Try it on the sample text, as shown in Listing 11.
Listing 11. Outputting misspellings in the sample text
$ spell Q1report.txt Smithwick earnigns $ spell -n Q1report.txt 13: Smithwick 19: earnigns $
But you can also use
ispell to spell check a file
interactively, where the contents of the file are shown on the screen and you
have a chance, at each potential misspelling, to correct or ignore it.
ispell finds a word that the system dictionary
doesn't recognize but that you know is correct—such as a proper
name—you can tell
ispell to ignore
it in that instance as well as in the rest of the file. You can also add the
word to your personal dictionary file; from then on, even in future
ispell will consider that word correct.
(When other users on the system use
ispell, the word
will be marked as incorrect unless they also add it to their personal
When a word appears uncapitalized in the dictionary, it's considered correct regardless of its capitalization. But, if the word is capitalized in the dictionary, it's considered correct only when so capitalized.
Table 2 shows the various commands for treating a misspelling.
Table 2. Table of International Ispell's word-check options
|number||Replace the misspelling with the word corresponding to the number.|
|R word||Replace the misspelling with word.|
|space||Accept the misspelling as correct in this location.|
|a||Accept the misspelling as correct in this location and for the remainder of the Ispell session.|
|i||Accept the misspelling as correct and insert it, with the capitalization as it appears, into your personal dictionary.|
|u||Accept the misspelling as correct and insert it, uncapitalized, into your personal dictionary.|
|l||Look up words in the dictionary.|
|x||Save changes and stop checking this file.|
|q||Abort the spelling check and quit the program.|
|!||Escape to a shell.|
||Redraw the terminal screen.|
||Display a help message.|
ispell on your sample text:
$ ispell Q1report.roff
When you do, your terminal will look like Figure 4.
Figure 4. Checking the sample text with International Ispell
At this point, Ispell has found and highlighted its first "misspelling," but you know that Smithwick's name is spelled correctly here. In fact, you know that Smithwick's name will be coming up in plenty of documents, so you want to add it to your personal dictionary. Add the word with the exact capitalization as it appears, so if it ever appears uncapitalized as "smithwick" in your documents, it will be properly treated as a misspelling.
Do so by typing
i to insert a copy of this word, as
it appears in the document, into your personal dictionary. After you've done
this, Ispell will have advanced to the next misspelling, the word "earnigns." On
most systems, it will have the correct word, "earnings," listed as the first
suggestion beneath the text—therefore corresponding with the numeral 0, as in
Figure 5. A spelling suggestion
0 to select the correct word, "earnings." After
you do this, Ispell exits, which means that it found no further misspellings in
Ispell doesn't limit you to checking plain, unformatted text: The
ispell tool recognizes several markup formats,
troff files. To check these files, use the