Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site dalcs.UUCP Path: utzoo!utcsri!dalcs!silvert From: silvert@dalcs.UUCP (Bill Silvert) Newsgroups: net.sources Subject: Re: spellfix - interactive spelling checker and fixer Message-ID: <1503@dalcs.UUCP> Date: Fri, 3-May-85 13:23:13 EDT Article-I.D.: dalcs.1503 Posted: Fri May 3 13:23:13 1985 Date-Received: Sat, 4-May-85 01:15:24 EDT References: <10091@brl-tgr.ARPA> Organization: Dalhousie University, Halifax, N.S., Canada Lines: 200 Here is an enhanced version of spellfix with the following features: menu driven rather than requiring editing of spell.errors in vi; supports user dictionary $HOME/dict/words and menu allows user to add words to this dictionary; option for automatic correction of words. This was created by modifying Rex Saunders' script, and he gets most of the credit for it. My changes are inspired mainly by the CP/M spelling checker "The Word Plus", which is a superb utility with these and more features. It has been suggested that spellfix check for complete words. That is too messy for my taste -- my spelling isn't that bad! Also, a recent item in net.sources.bugs points out that you can get into trouble with troff commands. Another problem which I haven't a fix for is case differences. I have chosen to ignore all words with embedded numerals (this includes 2nd) and anything which is all in capitals (since I write a lot of stuff with embedded Fortran code). ---------------------------cut here------------------------------- #! /bin/sh # run through /bin/sh to create script and manual entry cat > spellfix << xxSHELLxx #! /bin/sh # <@(#)spellfix Ver. 1.6, 85/04/29 12:03:48> - interactive spelling checker and fixer # Rex Sanders, USGS Pacific Marine Geology # Modifications by Bill Silvert, MEL t1=/tmp/spf$$.1 t2=/tmp/spf$$.2 t3=/tmp/spf$$.3 prog=`basename $0` udict=$HOME/dict uwords=$udict/words case $# in 1) trap 'rm -f $t1 $t2 $t3; exit' 0 1 2 15 ;; *) echo "Usage: $prog filename" >&2 exit 1 ;; esac echo "Looking for spelling errors in $1 ..." # ignore upper-case 'words' and alphnumerics spell $1 | grep "[a-z]" | grep -v "[0-9]" | sort > $t2 if test -s $uwords then sort -u $uwords -o $uwords # clean up user's dictionary comm -23 $t2 $uwords > $t1 else mv $t2 $t1 fi test -s $t1 || exit 0 test -d $udict || mkdir $udict echo "Found `wc -l <$t1` misspellings" echo "Responses: A=add to user dictionary, B=bypass" echo " C=correct, M=mark for correction" for word in `cat $t1` do grep $word $1 while : do echo -n "${word}: (A/B/C/M?) " read response case $response in A|a) echo $word >> $uwords break ;; B|b) break ;; C|c) echo -n "Correct spelling: " read response echo "s/${word}/${response}/" >> $t3 break ;; M|m) echo "/${word}/i\\" >> $t3 echo "### spell: ${word} %%%" >> $t3 break ;; *) ;; esac done done test -s $t3 || exit 0 if (sed -f $t3 < $1 > $t2 2> /dev/null) then echo "Here is a temporary copy of $1 to edit: use n to find next error" sleep 3 vi +/###/ $t2 sed -e '/^### spell: .* %%%$/d' $t2 > $t3 cp -i $t3 $1 else echo "spellfix: error marking misspelled words - file $1 unchanged." >&2 fi xxSHELLxx chmod +x spellfix cat >spellfix.1 <