Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Explore powerful UNIX writer's tools

Using new, open source equivalents of the classic UNIX Writer's Workbench

Michael Stutz, Author, Consultant
Photo of Michael Stutz
Michael Stutz is author of The Linux Cookbook, which he also designed and typeset using only open source software. His research interests include digital publishing and the future of the book. He has used various UNIX operating systems for 20 years.

Summary:  Long ago, UNIX® had a proprietary package called the Writer's Workbench (WWB). Developers, administrators, and technical writers who used to use this package in their work deeply miss it—its powerful capabilities made the UNIX workstation a preferred environment for document editing and proofreading. Today, many new implementations of those tools are available for all UNIX systems, and you can also find open source equivalents of the key WWB tools. Discover these tools and learn how to use them, building a custom style guide checker in the process.

Date:  22 May 2007
Level:  Intermediate

Activity:  15357 views
Comments:  

Using International Ispell

The UNIX 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.

WWB's 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.

Get a list of misspellings

The simplest way to use ispell is with GNU spell, which is a wrapper for ispell that provides the functionality of the old UNIX 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
$

Spell check a file interactively

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.

When 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 sessions, 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 dictionaries.)

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
KeyDescription
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.
aAccept the misspelling as correct in this location and for the remainder of the Ispell session.
iAccept the misspelling as correct and insert it, with the capitalization as it appears, into your personal dictionary.
uAccept the misspelling as correct and insert it, uncapitalized, into your personal dictionary.
lLook up words in the dictionary.
xSave changes and stop checking this file.
qAbort the spelling check and quit the program.
!Escape to a shell.
Ctrl-L Redraw the terminal screen.
Ctrl-Z Suspend Ispell.
? Display a help message.

Try running 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
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.


Figure 5. A spelling suggestion
A spelling suggestion

Type 0 to select the correct word, "earnings." After you do this, Ispell exits, which means that it found no further misspellings in the file.

Ispell doesn't limit you to checking plain, unformatted text: The ispell tool recognizes several markup formats, including troff files. To check these files, use the -n option.

4 of 10 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=AIX and UNIX
ArticleID=220108
TutorialTitle=Explore powerful UNIX writer's tools
publish-date=05222007
author1-email=stutz@dsl.org
author1-email-cc=mmccrary@us.ibm.com