This assignment is due Tuesday, April 14 before class time. Do this assignment on turing.cs.niu.edu or hopper.cs.niu.edu. It is worth 100 points. No late homework.

Submission:

To receive credit for this assignment you must turn in a hardcopy of your script AND a machine-readable version using the following rules.

Hardcopy: (Same rules as before.) Assignments must be stapled. Written homework must be turned in at the beginning of the class period to be considered on time. Print programs using non-proportional type (e.g., Courier) in at least 10 point size. You may use proportional type for answers to questions, but make sure the type size is at least as large as what you are reading (i.e., 12 point). This means that you may not print 2-up. Homework should be turned in on 8 1/2 x 11 paper and must be stapled together. The upper right corner of the first page should contain (a) your name, (b) CS330, (c) the assignment number, (d) the date. If you cannot attend class, written assignments will be considered on time if they are left under my office door provided they are received before class time.

Machine-readable: (a) Name your script hw3-xxxx, where xxxx = the first four letters of your last name. (If your last name has fewer than four letters, just use your last name.) (b) Email your script as an attachment to your TA at z139048. Note: no machine name, just the z-number. Email from turing/hopper cannot go outside the cluster; this form will send email within the cluster, regardless of which machine your account is located on. (c) Your script must be mailed as an attachment, not included in the body of the email. (d) The subject line should also say hw3-xxxx.

One email program you can use is alpine. (This is the one used by Linus Torvalds, the originator of linux.) Start it with the alpine command. The first time you will get a message about being counted as an alpine user. After that, use 'c' to compose your email, then fill in the "to" address (z139048), the name of your attachment, and the subject. Then say "hi" to your TA in the body of the email, just so it won't be blank. Finally, use 'x' to send your message, confirming with 'y' when asked.

Overview:

Write a shell script that implements an interactive spell checker.

The general format for invocation is:

      wordspell file

where "wordspell" is the name of the executable file that contains your shell script (written in csh commands), and "file" refers to the file to be checked word-by-word for spelling.

Your are encouraged to take advantage of the "ispell -l" command. It reads from standard input and writes a list of misspelled words on standard output.

Specification:

wordspell reads "file" and checks it for spelling of the words it contains. wordspell is invoked interactively. For each word that is found to be incorrect, the invoker is asked:

If the invoker insists on the spelling of the word, then this word is added to wordspell's memory.

wordspell remembers words in the file "memory" in the invoker's home directory. Any further invocation of wordspell by the same invoker will consider the word to be correct.

Otherwise the invoker is prompted for a replacement spelling. As output, wordspell produces a 2-column list of words. The left column lists incorrectly spelled words, the right column lists their replacement as given by the invoker. The list is produced after all the words have been processed.

Here is an example of an invocation of the wordspell script with a test file:


% ls -1
testfile.txt  
wordspell

% cat testfile.txt
I was running along quite nicely
when I was acosted by the mail man
whio insisted that my name is Raimund Ege
but I did not believe him

% ./wordspell testfile.txt

'acosted' is misspelled. Press "Enter" to keep
this spelling, or type a correction here: accosted

'whio' is misspelled. Press "Enter" to keep
this spelling, or type a correction here: who

'Raimund' is misspelled. Press "Enter" to keep
this spelling, or type a correction here: 

'Ege' is misspelled. Press "Enter" to keep
this spelling, or type a correction here: 

MISSPELLED:             CORRECTIONS:
acosted                 accosted
whio                    who

% ./wordspell testfile.txt

'acosted' is misspelled. Press "Enter" to keep
this spelling, or type a correction here: accosted

'whio' is misspelled. Press "Enter" to keep
this spelling, or type a correction here: who

MISSPELLED:             CORRECTIONS:
acosted                 accosted
whio                    who

% cat ~/memory
Raimund
Ege

% cat testfile.txt
I was running along quite nicely
when I was acosted by the mail man
whio insisted that my name is Raimund Ege
but I did not believe him


Additional Notes: