Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site isosvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!qantel!hplabs!hao!noao!terak!asuvax!isosvax!oer From: oer@isosvax.UUCP (Ed Reeder) Newsgroups: net.sources Subject: spellfix enhancements Message-ID: <241@isosvax.UUCP> Date: Fri, 11-Oct-85 18:40:09 EDT Article-I.D.: isosvax.241 Posted: Fri Oct 11 18:40:09 1985 Date-Received: Tue, 15-Oct-85 10:28:50 EDT Organization: Intel Corp, Phoenix (Deer valley), AZ Lines: 275 Enclosed is yet another set of enhancements to spellfix, a spelling corrector previously distributed by Bill Silvert. I corrected a few minor bugs, made it also operate on XENIX systems, added an ability to look up correct spellings in real time (using look), and way to specify an editor other than vi. I am enclosing Bill's original commentary. I have tested this on UCB 4.2 and Intel's version of XENIX (a superior, and compatible, version of the XENIX available on the PC/AT). Ed Reeder Intel Corporation Phoenix, AZ -----------------Bill's Commentary--------------------------------- 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.7, 85/09/27 12:03:48> - interactive spelling checker and fixer # Rex Sanders, USGS Pacific Marine Geology # Modifications by Bill Silvert, MEL # Modifications by Ed Reeder, Intel t1=/tmp/spf$$.1 t2=/tmp/spf$$.2 t3=/tmp/spf$$.3 prog=`basename $0` udict=$HOME/dict uwords=$udict/words SPELLEDITOR=${SPELLEDITOR-'vi +/###/'} 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 | egrep "[a-z]" | egrep -v "[0-9]" | sort > $t2 if test -s $uwords then uwexists=y sort -u -f $uwords -o $uwords # clean up user's dictionary. sort $uwords | comm -23 $t2 - > $t1 # comm won't work with folded order 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, C=correct" echo " L=look for correct spelling, M=mark for correction" for word in `cat $t1` do egrep $word $1 while : do echo -n "${word}: (A/B/C/L/M?) " read response case $response in A|a) echo $word >> $uwords break ;; B|b) break ;; C|c) echo -n "Correct spelling: " read response case $response in "") continue ;; esac echo "s/${word}/${response}/" >> $t3 break ;; L|l) echo -n "First letters of word: " read response case $response in "") continue ;; esac case $uwexists in y) look -f $response $uwords > $t2 look $response | sort -f -m - $t2 ;; *) look $response ;; esac | more ;; M|m) echo "/${word}/i\\" >> $t3 echo "### spell: ${word} %%%" >> $t3 mark=y break ;; *) ;; esac done done test -s $t3 || exit 0 if (sed -f $t3 < $1 > $t2 2> /dev/null) then case "$mark" in y) echo "Here is a temporary copy of $1 to edit: use n to find next error" echo "The errors are marked by the ### character string" sleep 3 $SPELLEDITOR $t2 sed -e '/^### spell: .* %%%$/d' $t2 > $t3 ;; *) mv $t2 $t3 ;; esac while : do echo -n "Do you want to overwrite $1 ? " read reply case "$reply" in y*|Y*) cp $t3 $1 exit 0 ;; n*|N*) exit 0 ;; *) continue ;; esac done else echo "$prog: error marking misspelled words - file $1 unchanged." >&2 fi xxSHELLxx chmod +x spellfix cat >spellfix.1 <