[net.sources] spelling checker with personal dictionaries

perlman@wanginst.UUCP (Gary Perlman) (01/12/85)

Someone asked for an improved spelling checker.
What follows is not a great leap of the imagination,
but it allows personal dicitonaries you can add your
words to (with spadd) and a less space consuming output
format (the spelling checker sp uses a simple program: cols).
Please don't complain about how simple it is; at least it's
an improvement over spell.

Gary Perlman/Wang Institute/Tyngsboro, MA/01879/(617) 649-9731

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
-----cut here-----cut here-----cut here-----cut here-----
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	makefile
#	sp
#	spadd
#	cols.c
# This archive created: Sat Jan 12 14:08:26 1985
# By:	Gary Perlman (Wang Institute, Tyngsboro, MA 01879 USA)
echo shar: extracting makefile '(170 characters)'
cat << \SHAR_EOF > makefile
DESTDIR=/usr/local/bin
CFLAGS=-O
install: cols sp spadd
	chmod 755 sp spadd
	-mv cols $(DESTDIR)
	-mv sp $(DESTDIR)
	-mv spadd $(DESTDIR)
cols: cols.o
	cc -o cols cols.o
SHAR_EOF
echo shar: extracting sp '(393 characters)'
cat << \SHAR_EOF > sp
#!/bin/sh
PATH=/usr/bin:/bin:/usr/local/bin
export PATH
LIB=$HOME/lib
DICT=$LIB/dict
if test ! -d $LIB
then
	echo creating library directory: $LIB
	mkdir $LIB
fi
if test ! -r  $DICT
then
	echo creating personal spelling file: $DICT
	/bin/cp /dev/null $DICT
fi
echo Possible Spelling Errors: $*
spell $* |
	sort |
	comm -23 - $DICT |
	cols 6
echo "Use spadd to add correct words to your list."
SHAR_EOF
echo shar: extracting spadd '(280 characters)'
cat << \SHAR_EOF > spadd
#!/bin/sh
PATH=/usr/bin:/bin
LIB=$HOME/lib
DICT=$LIB/dict
if test ! -d $LIB
then
	echo creating library directory: $LIB
	mkdir $LIB
fi
if test ! -r  $DICT
then
	echo creating personal spelling file: $DICT
	/bin/cp /dev/null $DICT
fi
for i
do
	echo $i
done | sort -o $DICT - $DICT
SHAR_EOF
echo shar: extracting cols.c '(831 characters)'
cat << \SHAR_EOF > cols.c
/*
	This program produces n column output from its input.
	It is meant to reformat output from programs with
	one column output.  It could be replaced with "paste"
	but some sites don't have that program.

	Its only option sets the number of columns (default 1).

	Gary Perlman/Wang Institute/Tyngsboro, MA/01879/(617) 649-9731
*/

#include <stdio.h>

#define	WIDTH	72
#define	HWIDTH	WIDTH/2

main (argc, argv)
char **argv;
	{
	int 	cols = 1;
	int 	width = 0;
	int 	col = 0;
	char	buf[BUFSIZ];
	if (argc > 1)
		{
		cols = atoi (argv[1]);
		if (cols <= 0) cols = 1;
		else if (cols > HWIDTH) cols = HWIDTH;
		width = WIDTH / cols;
		}
	while (scanf ("%s", buf) > 0)
		{
		if (col != 0) putchar (' ');
		printf ("%-*s", width, buf);
		if (++col >= cols)
			{
			col = 0;
			putchar ('\n');
			}
		}
	if (col != 0) putchar ('\n');
	}
SHAR_EOF
#	End of shell archive
exit 0