spellfix - interactive spelling checker and fixer

Laura Creighton laura at utzoo.UUCP
Tue Apr 23 17:56:03 AEST 1985


Hello there. I have my own interactive spelling fixer. It doesn't
munge up your files or dump you into vi. It uses sed. It doesn't have
a manual page (what do you expect for a 1/2 hour hack that I never
thought anybody else would want?). What you do is to run spell on your
magnum opus to get a list of errors. Put them in spell.errs (well, if
you don't like that name you can define it to be something else in your
environment). Then run ispell. It will prompt you for every error.
``y'' is -- yes, that's an error, but I don't know how to spell it;
``n'' is -- no, ``Creighton'' *isn't* a spelling error, you stupid program,
and anything else is a correct spelling. You can keep error lists around
until you find a dictionary. You can do shell escapes. It catches signals
properly. 

There is one known problem. If you mispell the word ``the'' as ``teh''
(to pick a random example you will *never* see in any news articles
posted by me :-) ) it will munge all words that have ``teh'' in them.
So you had better run spell one last time when you are done.

Flash Bulletin! Geoff Collyer thinks it is spiffo! He is going to write me a
manual page on the spot. Thanks Geoff...

Manual page written. Oh -- the program uses ``overwrite(1)'' which is
found on page 154 of Kernighan and Pike. If you don't have this book,
you should probably buy it -- it is good stuff. If you can't figure out
how to write overwrite from context, then you *definitely* should buy it -
by the time you finish reading the first 4 chapters you won't have this
problem.


Laura Creighton
utzoo!laura (but not for long... yippee!)

-------------here is ispell-----------------------
#! /bin/sh
# ispell - an interactive spelling checker

case $#
in
	0)	echo "usage: $0 filenames" >&2; exit 1 ;;
esac

: ${SPELLERRS=spell.errs}	# the list of mistakes
: ${SPELLFILE=/tmp/ispell$$}	# the temporary file of unfixed mistakes
: ${SPELLFIX=/tmp/ispellf$$}	# the temporary file of sed commands

trap "rm -f $SPELLFILE $SPELLFIX; exit 1" 1 2 15	# clean up files

for mistake in `cat $SPELLERRS`
do
	echo -n "$mistake? "
	read correction
	case "$correction" in
	q|Q)	break ;;
	y|Y|"")	echo $mistake >> $SPELLFILE ;;
	n|N)	;;
	!*)	trap "echo !; continue" 1 2 15	# child gets signals,
			# parent ignores them
			# this means that you can type
			# interrupts without blowing away the
			# whole session.
		command=`echo "$correction" | sed 's@^.@@'`
		$command
		trap "rm -f $SPELLFILE $SPELLFIX; exit 1" 1 2 15
			# catch signals again
		echo !
		echo $mistake >> $SPELLFILE ;; 
			# don't lose it, you can always delete it later
	*)	echo s@$mistake@$correction at g >> $SPELLFIX ;;
	esac
done

if test -s $SPELLFIX
then
	for i
	do
		overwrite $i sed -f $SPELLFIX $i
	done
fi

if test -s $SPELLFILE
then
	mv $SPELLFILE $SPELLERRS
else
	rm -f $SPELLFILE $SPELLERRS
fi
rm -f $SPELLFIX

----------and this is the brand new manual page!!!--------------
.TH ISPELL 1 local
.DA 23 April 1985
.SH NAME
ispell \- interactive spelling repair
.SH SYNOPSIS
.B ispell
file...
.SH DESCRIPTION
.I Ispell
corrects spelling errors (as verified by the user) in
.IR file s.
Errors are assumed to be found in
.I spell.errs
(overridden by the environment variable SPELLERRS),
which
.I ispell
maintains.
.I Ispell
prompts the user for each misspelling and asks how to correct it.
.PP
If the user types
.BR n ,
the misspelling is discarded.
If the user types
.B y
or a newline,
the misspelling is retained but not corrected.
A line beginning with
.B !
is taken to be a shell escape and the misspelling is retained.
Any other response is assumed to be the corrected form of
the misspelling and will be corrected after the last reply has been typed.
If the user types
.BR q ,
.I ispell
discards the remaining misspellings
(probably because you know the remaining ones are correct)
and applies any corrections accumulated so far.
.SH FILES
spell.errs	running list of potential mistakes
.br
/tmp/ispell$$	new spell.errs being created
.br
/tmp/ispellf$$	sed commands to correct the mistakes
.SH SEE ALSO
spell(1), overwrite(1)
.SH HISTORY
Written by Laura Creighton in a fit of desperation when proof-reading
a long manuscript; manual page by Geoff Collyer so she wouldn't have
to post the source without this page.
.SH BUGS
Shell escapes probably shouldn't assume that you don't know
the correction and should prompt for the mistake again.
.PP
Correcting a short word may break longer words in which the short misspelling
appears.



More information about the Comp.sources.unix mailing list