Bell 32V development
authorTom London <tbl@research.uucp>
Mon, 6 Nov 1978 04:35:20 +0000 (23:35 -0500)
committerTom London <tbl@research.uucp>
Mon, 6 Nov 1978 04:35:20 +0000 (23:35 -0500)
Work on file usr/src/cmd/spell/american
Work on file usr/src/cmd/spell/british
Work on file usr/src/cmd/spell/spell.h
Work on file usr/src/cmd/spell/spellout.c
Work on file usr/src/cmd/spell/spellin.c

Co-Authored-By: John Reiser <jfr@research.uucp>
Synthesized-from: 32v

usr/src/cmd/spell/american [new file with mode: 0644]
usr/src/cmd/spell/british [new file with mode: 0644]
usr/src/cmd/spell/spell.h [new file with mode: 0644]
usr/src/cmd/spell/spellin.c [new file with mode: 0644]
usr/src/cmd/spell/spellout.c [new file with mode: 0644]

diff --git a/usr/src/cmd/spell/american b/usr/src/cmd/spell/american
new file mode 100644 (file)
index 0000000..7015f97
--- /dev/null
@@ -0,0 +1,319 @@
+acknowledgment
+aggrandize
+aluminize
+aluminum
+amor
+amorous
+amphitheater
+analog
+analyze
+anemia
+anemic
+anesthesia
+anesthetic
+anesthetize
+antagonize
+apologize
+appareled
+appareling
+appetize
+arbor
+archeology
+ardor
+arithmetize
+armor
+armory
+axiomatize
+baptize
+barreled
+barreling
+behavior
+behoove
+belabor
+beveled
+beveler
+beveling
+canceled
+canceler
+canceling
+candor
+catalog
+catalyze
+catechize
+categorize
+cauterize
+center
+channeled
+channeler
+channeling
+chiseled
+chiseler
+chiseling
+clamor
+clamorous
+clangor
+color
+colorable
+colorful
+colorist
+corbeled
+corbeling
+counseled
+counseling
+crystallize
+cudgeled
+cudgeler
+cudgeling
+decentralize
+decriminalize
+defense
+dehumanize
+deionize
+demagnetize
+demeanor
+demineralize
+demoralize
+depersonalize
+depolarize
+desensitize
+detribalize
+dialyze
+diarrhea
+discolor
+disemboweled
+disemboweling
+disfavor
+disheveled
+disheveler
+disheveling
+dishonor
+dishonorable
+disorganize
+doweled
+doweler
+doweling
+dramatize
+dueled
+dueler
+dueling
+duelist
+economize
+ecumenical
+edema
+emphasize
+enameled
+enameling
+enamor
+encyclopedia
+endeavor
+energize
+eon
+epicenter
+esophagus
+eulogize
+favor
+favorable
+favorite
+fervor
+fiber
+flavor
+fraternize
+fueled
+fueler
+fueling
+funneled
+funneler
+funneling
+furor
+galvanize
+gaveled
+gaveler
+gaveling
+glamorize
+gram
+graveled
+graveling
+groveled
+groveler
+groveling
+gynecology
+harbor
+harmonize
+hiccup
+hiccupped
+hiccupping
+homeopathy
+homogenize
+honor
+honorable
+humor
+hydrolyze
+hypnotize
+hypostatize
+hypothesize
+jeweled
+jeweler
+jeweling
+judgment
+kilogram
+kinesthetic
+labeled
+labeler
+labeling
+labor
+laborite
+legitimize
+leveled
+leveler
+leveling
+libeled
+libeler
+libeling
+license
+liter
+logorrhea
+louver
+luster
+marveled
+marveler
+marveling
+mechanize
+medieval
+memorize
+mesmerize
+metallize
+milligram
+milliliter
+millimeter
+modeled
+modeler
+modeling
+nanogram
+naught
+neighbor
+neighborhood
+notarize
+ocher
+odor
+offense
+optimize
+orientation
+ostracize
+pajama
+pallor
+paneled
+paneling
+paralleled
+paralleling
+paralyze
+parametrize
+parceled
+parceler
+parceling
+parenthesize
+parlor
+peptize
+photolyze
+photosynthesize
+picogram
+plagiarize
+preprogram
+program
+proselytize
+psychoanalyze
+psycoanalyze
+pulverize
+pummeled
+pummeler
+pummeling
+pyorrhea
+pyrolyze
+quantize
+quarreled
+quarreler
+quarreling
+rancor
+raveled
+raveler
+raveling
+realize
+recognize
+reconnoiter
+reveled
+reveler
+reveling
+rigor
+rumor
+saber
+saltpeter
+savior
+savor
+savory
+scepter
+schematize
+scrutinize
+sensitize
+sepulcher
+shoveled
+shoveler
+shoveling
+shriveled
+shriveling
+siphon
+sniveled
+sniveler
+sniveling
+soliloquize
+specialty
+specter
+spirochete
+splendor
+squirreled
+squirreling
+stigmatize
+succor
+summarize
+swiveled
+swiveling
+symmetrize
+sympathize
+synchronize
+synthesize
+systematize
+tantalize
+tasseled
+tasseling
+temporize
+theater
+theatergoer
+theatergoing
+theorize
+tinseled
+tinseling
+titer
+toweled
+toweling
+trammeled
+traumatize
+traveled
+traveler
+traveling
+tricolor
+tumor
+tunneled
+tunneler
+tunneling
+tyrannize
+valor
+vapor
+varicolored
+vigor
+vulcanize
+wagon
+watercolor
+watercolorist
+weaseled
+weaseling
+whiskey
+yodeled
+yodeling
diff --git a/usr/src/cmd/spell/british b/usr/src/cmd/spell/british
new file mode 100644 (file)
index 0000000..9d58195
--- /dev/null
@@ -0,0 +1,324 @@
+acclimatise
+aeon
+aerodrome
+aeroplane
+aggrandise
+alarum
+aluminium
+amour
+amourous
+amphitheatre
+anaemia
+anaemic
+anaesthesia
+anaesthetic
+anaesthetise
+analyse
+antagonise
+apologise
+apparelled
+apparelling
+appetise
+arbour
+archaeology
+ardour
+arithmetise
+armour
+armoury
+axiomatise
+baptise
+barrelled
+barrelling
+behaviour
+behavioural
+behove
+belabour
+bevelled
+beveller
+bevelling
+cancelled
+canceller
+cancelling
+candour
+catalyse
+catechise
+categorise
+cauterise
+centimetre
+centre
+channelled
+channeller
+channelling
+cheque
+chequer
+chiselled
+chiseller
+chiselling
+clamour
+clamourous
+clangour
+colour
+colourable
+colourist
+connexion
+corbelled
+corbelling
+counselled
+counselling
+crystallise
+cudgelled
+cudgeller
+cudgelling
+decentralise
+decriminalise
+defence
+dehumanise
+deionise
+demagnetise
+demeanour
+demineralise
+demoralise
+depersonalise
+depolarise
+desensitise
+detribalise
+dialyse
+diarrhoea
+discolour
+disembowelled
+disembowelling
+disfavour
+dishevelled
+disheveller
+dishevelling
+dishonour
+dishonourable
+disorganise
+dowelled
+doweller
+dowelling
+dramatise
+draught
+duelled
+dueller
+duelling
+duellist
+economise
+emphasise
+enamelled
+enamelling
+enamour
+encyclopaedia
+endeavour
+energise
+epicentre
+eulogise
+favour
+favourable
+favourite
+fervour
+fibre
+flavour
+fraternise
+fuelled
+fueller
+fuelling
+funnelled
+funneller
+funnelling
+furore
+fuze
+galvanise
+gaol
+gavelled
+gaveller
+gavelling
+glamourise
+gramme
+gravelled
+gravelling
+grovelled
+groveller
+grovelling
+gynaecology
+harbour
+harmonise
+homoeopathy
+homogenise
+honour
+honourable
+humour
+hydrolyse
+hypnotise
+hypostatise
+hypothesise
+jewelled
+jeweller
+jewelling
+kilogramme
+kilometre
+kinaesthetic
+labelled
+labeller
+labelling
+labour
+labourite
+legitimise
+levelled
+leveller
+levelling
+libelled
+libeller
+libelling
+licence
+litre
+logorrhoea
+lustre
+marvelled
+marveller
+marvelling
+mechanise
+mediaeval
+memorise
+mesmerise
+metallise
+metre
+milligramme
+millilitre
+millimetre
+modelled
+modeller
+modelling
+nanogramme
+nanometre
+neighbour
+neighbourhood
+notarise
+nought
+ochre
+odour
+oecumenical
+oedema
+oesophagus
+offence
+optimise
+orientate
+ostracise
+pallour
+panelled
+panelling
+parallelled
+parallelling
+paralyse
+parametrise
+parcelled
+parceller
+parcelling
+parenthesise
+parlour
+peptise
+photolyse
+photosynthesise
+picogramme
+plagiarise
+practise
+preprogramme
+programme
+proselytise
+psychoanalyse
+pulverise
+pummelled
+pummeller
+pummelling
+pyjama
+pyorrhoea
+pyrolyse
+quantise
+quarrelled
+quarreller
+quarrelling
+rancour
+ravelled
+raveller
+ravelling
+realise
+recognise
+reconnoitre
+revelled
+reveller
+revelling
+rigour
+rumour
+sabre
+saltpetre
+saviour
+savour
+savoury
+sceptre
+schematise
+scrutinise
+sensitise
+sepulchre
+shovelled
+shoveller
+shovelling
+shrivelled
+shrivelling
+snivelled
+sniveller
+snivelling
+soliloquise
+speciality
+spectre
+splendour
+squirrelled
+squirrelling
+stigmatise
+succour
+summarise
+millimetre
+swivelled
+swivelling
+symmetrise
+sympathise
+synchronise
+synthesise
+syphon
+systematise
+tantalise
+tasselled
+tasselling
+temporise
+theatre
+theorise
+tinselled
+tinselling
+titre
+towelled
+towelling
+trammelled
+traumatise
+travelled
+traveller
+travelling
+tricolour
+tumour
+tunnelled
+tunneller
+tunnelling
+tyrannise
+tyre
+valour
+vapour
+varicoloured
+vigour
+vulcanise
+waggon
+watercolour
+watercolourist
+weaselled
+weaselling
+whilst
+whisky
+yodelled
+yodelling
diff --git a/usr/src/cmd/spell/spell.h b/usr/src/cmd/spell/spell.h
new file mode 100644 (file)
index 0000000..6ed377c
--- /dev/null
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <ctype.h>
+
+#ifndef unix
+#define SHIFT  5
+#define TABSIZE (int)(400000/(1<<SHIFT))
+int    *tab;   /*honeywell loader deficiency*/
+#else
+#define Tolower(c)     (isupper(c)?tolower(c):c) /* ugh!!! */
+#define SHIFT  4
+#define TABSIZE 25000  /*(int)(400000/(1<<shift))--pdp11 compiler deficiency*/
+short  tab[TABSIZE];
+#endif
+long   p[] = {
+       399871,
+       399887,
+       399899,
+       399911,
+       399913,
+       399937,
+       399941,
+       399953,
+       399979,
+       399983,
+       399989,
+};
+#define        NP      (sizeof(p)/sizeof(p[0]))
+#define        NW      30
+
+/*
+* Hash table for spelling checker has n bits.
+* Each word w is hashed by k different (modular) hash functions, hi.
+* The bits hi(w), i=1..k, are set for words in the dictionary.
+* Assuming independence, the probability that no word of a d-word
+* dictionary sets a particular bit is given by the Poisson formula
+* P = exp(-y)*y**0/0!, where y=d*k/n.
+* The probability that a random string is recognized as a word is then
+* (1-P)**k.  For given n and d this is minimum when y=log(2), P=1/2,
+* whence one finds, for example, that a 25000-word dictionary in a
+* 400000-bit table works best with k=11.
+*/
+
+long   pow2[NP][NW];
+
+prime(argc, argv) register char **argv;
+{
+       int i, j;
+       long h;
+       register long *lp;
+
+#ifndef unix
+       if ((tab = (int *)calloc(sizeof(*tab), TABSIZE)) == NULL)
+               return(0);
+#endif
+       if (argc > 1) {
+               FILE *f;
+               if ((f = fopen(argv[1], "ri")) == NULL)
+                       return(0);
+               if (fread((char *)tab, sizeof(*tab), TABSIZE, f) != TABSIZE)
+                       return(0);
+               fclose(f);
+       }
+       for (i=0; i<NP; i++) {
+               h = *(lp = pow2[i]) = 1<<14;
+               for (j=1; j<NW; j++)
+                       h = *++lp = (h<<7) % p[i];
+       }
+       return(1);
+}
+
+#define get(h) (tab[h>>SHIFT]&(1<<((int)h&((1<<SHIFT)-1))))
+#define set(h) tab[h>>SHIFT] |= 1<<((int)h&((1<<SHIFT)-1))
diff --git a/usr/src/cmd/spell/spellin.c b/usr/src/cmd/spell/spellin.c
new file mode 100644 (file)
index 0000000..3f46c2b
--- /dev/null
@@ -0,0 +1,40 @@
+#include "spell.h"
+/* add entries to hash table for use by spell
+   preexisting hash table is first argument
+   words to be added are standard input
+   if no hash table is given, create one from scratch
+*/
+
+main(argc,argv)
+char **argv;
+{
+       register i, j;
+       long h;
+       register long *lp;
+       char word[NW];
+       register char *wp;
+
+       if(!prime(argc,argv)) {
+               fprintf(stderr,
+                   "spellin: cannot initialize hash table\n");
+               exit(1);
+       }
+       while (fgets(word, sizeof(word), stdin)) {
+               for (i=0; i<NP; i++) {
+                       for (wp = word, h = 0, lp = pow2[i];
+                                (j = *wp) != '\0'; ++wp, ++lp)
+                               h += j * *lp;
+                       h %= p[i];
+                       set(h);
+               }
+       }
+#ifdef gcos
+       freopen((char *)NULL, "wi", stdout);
+#endif
+       if (fwrite((char *)tab, sizeof(*tab), TABSIZE, stdout) != TABSIZE) {
+               fprintf(stderr,
+                   "spellin: trouble writing hash table\n");
+               exit(1);
+       }
+       return(0);
+}
diff --git a/usr/src/cmd/spell/spellout.c b/usr/src/cmd/spell/spellout.c
new file mode 100644 (file)
index 0000000..91fa6c9
--- /dev/null
@@ -0,0 +1,43 @@
+#include "spell.h"
+
+main(argc, argv)
+char **argv;
+{
+       register i, j;
+       long h;
+       register long *lp;
+       char word[NW];
+       int dflag = 0;
+       int indict;
+       register char *wp;
+
+       if (argc>1 && argv[1][0]=='-' && argv[1][1]=='d') {
+               dflag = 1;
+               argc--;
+               argv++;
+       }
+       if(argc<=1) {
+               fprintf(stderr,"spellout: arg count\n");
+               exit(1);
+       }
+       if(!prime(argc,argv)) {
+               fprintf(stderr,
+                   "spellout: cannot initialize hash table\n");
+               exit(1);
+       }
+       while (fgets(word, sizeof(word), stdin)) {
+               indict = 1;
+               for (i=0; i<NP; i++) {
+                       for (wp = word, h = 0, lp = pow2[i];
+                               (j = *wp) != '\0'; ++wp, ++lp)
+                               h += j * *lp;
+                       h %= p[i];
+                       if (get(h)==0) {
+                               indict = 0;
+                               break;
+                       }
+               }
+               if (dflag == indict)
+                       fputs(word, stdout);
+       }
+}