Previous Table of Contents Next


Module 123
spell

DESCRIPTION

The external spell command checks input for spelling errors. It compares the words it reads from input to words in its spelling list. If a word is not located in its list, then the word is printed on the standard output. spell adds suitable prefixes, suffixes, and inflections to derive the correct spelling of a word.

Most troff, nroff, tbl, eqn, and pic constructions are ignored by spell. The deroff command is executed by spell to remove these constructs.

By default spell follows chains of troff and nroff include files. Include files are preceded by .so or .nx constructs. If the filename begins with /usr/lib, spell ignores the file and does not read it. Most /usr/lib files are mm macros created by vendors, not by users. If the -l option is specified, then all include files are read, even the /usr/lib files.

The spelling list file was created from many sources. Although it is not a Webster's Dictionary, it is very effective with respect to proper names and technical words. Unfortunately, the coverage of special professions such as biology, chemistry, and medicine is lacking to say the least.

The hashmake command converts a list of words to a list of nine-digit hash codes. The list of words are read from the standard input. The list of hash codes are written to the standard output. The output of hashmake is an intermediate file used by spellin to create the final spelling list (hlist).

The spellin command converts hash codes to a hashed compressed spelling list. The hash codes are read from the standard input. The compressed spelling list is written to the standard output. The output of spellin is the final spelling list used by spell; the file is referred to as the hlist.

The hashcheck command converts a compressed spelling list to a list of hash codes. The compressed spelling list is read from the standard input. The hash code list is written to the standard output. You use the hashcheck command to verify that the compressed spelling list is valid.


BSD (Berkeley)
The spellin command creates a hashed compressed spelling list. The ASCII word list is read from the standard input. If a filename is given it is assumed to be an existing spelling list file (hlist). The output, a new or updated spelling list, is written to the standard output.
The spellout command searches the given hashed spelling list (hlist) for each word read from the standard input. If the list does not contain one of the input words, the word is written to the standard output. With the -d option specified, the word is written to the standard output if it does exist in the hashed list.

COMMAND FORMAT

Following is the general format of the spell command.

     spell [ -blvx ] [ +local_file ] [ file_list ]
     /usr/lib/spell/hashmake
     /usr/lib/spell/spellin n
     /usr/lib/spell/hashcheck word_list

BSD (Berkeley)
spell [ -bvx ] [ -d hlist ] [ -h spellhist ] [ -s hstop ] [ file ]
spellin [ list ]
spellout [ -d ] list

Most users only use the spell command. The other commands are usually used by the system administrator to add words to the spelling list.

Options

The following list describes the options and their arguments that may be used to control how spell functions.

-b Check for British spelling. The ise ending is required in words such as standardize. Such spelling as colour and centre are checked.
-l Causes the files referenced in a troff document to be read even if their pathname begins with /usr/lib. Normally spell will check the spelling of chained files in a troff document, unless the pathname of the file begins with /usr/lib. Chained files are .so and .nx requests in a troff document.
-v Displays all words not literally in the spelling list. All reasonable alternative words are displayed if any exist.
-x Displays possible stems, prefixed with an equal sign (=), for each word being checked.
+local_file Words listed in local_file are removed from spell's output of misspelled words. The local_file contains a sorted list of words, one per line. You can use this file to store a list of correctly spelled words unknown to the normal spelling list (hlist).

BSD (Berkeley)
-d hlist Use hlist as the spelling list file instead of the default. The default is /usr/dict/hlist[ab].
-h spellhist Use spellhist as the history file instead of the default. The default is /dev/null. The history file contains a copy of all words spelled incorrectly according to spell.
-s hstop Use hstop as the stop list file instead of the default. The default is /usr/dict/hstop.
See the following section "Control Files" for definitions of these three files.

Arguments

The following list describes the arguments that may be passed to the spell command.

file_list One or more files read and each word checked for correct spelling.
If no files are listed the standard input is read for words.

Control Files

The following files are used by spell to verify the correct spelling of the input word list.

hlist The list of correctly spelled words in hashed format.
spellhist Copies of all output. This provides the system administrator with a list of words that have been rejected by spell as incorrect. Technical words may be taken from the list and added to the list of correctly spelled words (hlist).
hstop The list of words used to filter out words that pass the normal spell checking. For example, their=they-ey+eir.

The following environment variables may be set to override the default files used by spell. They correspond to the BSD -d, -h, and -s options.

D_SPELL=hlist Defines your hlist file instead of the default. The default is /usr/lib/spell/ hlist[ab].
H_SPELL=spellhist Defines your spellhist file instead of the default. The default is /usr/lib/ spell/spellhist.
S_SPELL=hstop Defines your hstop file instead of the default. The default is /usr/lib/spell/ hstop.

Generating New hlist

To generate a new hlist (correctly spelled words) perform the following steps.

1.  Create a list of correctly spelled words. Use vi or another favorite editor. Name the file goodwords.
2.  Type cat goodwords | /usr/lib/spell/hashmake | sort -u > gw1 and press Return. This creates a temporary hash list of the new words.
3.  Type cat gw1 | /usr/lib/spell/spellin `cat gw1 | wc -l` > hlist and press Return. This creates a compressed list of correctly spelled words (a spelling list).

To check the hash list.

4.  Type cat hlist | /usr/lib/spell/hashcheck > gw2 and press Return. This creates a list of hash codes for the corresponding compressed spelling list.
5.  Type diff gw1 gw2 and press Return. This verifies that the new spelling list (hlist) is correct. If the hash list (hlist) is correct no output is displayed.
6.  Type rm gw1 gw2 and press Return to remove the work files.

You now have a correct and functional hlist file to use for your own words.


BSD (Berkeley)
1. Create a list of correctly spelled words. Use vi or another favorite editor. Name the file goodwords.
2. Type cat goodwords | spellin > hlist and press Return. This creates a hashed spelling list.
To check the hash list.
3. Type cat goodwords | spellout hlist and press Return. Any words in goodwords not in the hash list (hlist) are displayed on your terminal.

DIAGNOSTICS AND BUGS

New installations will probably find it necessary to monitor the output of spell on local documents to collect a local spelling list. Once the list is collected, a new local list can be added to spell's list of words.

RELATED FILES

The spell command reads from files or from the standard input. It writes any misspelled words to the standard output. It uses different files for spell checking located in the /usr/lib/spell directory.

APPLICATIONS

The spell command is used to check your documents for spelling errors. Unfortunately, it is not interactive in correcting the misspelled words, nor does it suggest correct spellings.

TYPICAL OPERATION

In this activity you use the spell command to check the spelling of words in a file. Begin at the shell prompt.

1.  Type spell file1 and press Return. If no output is returned to your screen, then no words are misspelled in the file1 file. The output should resemble the following.
   cj> spell file1
   file1
2.  If you would like to see more misspelled words type spell /etc/passwd and press Return.
3.  Turn to Module 140 to continue the learning sequence.


Previous Table of Contents Next