/* @(#)spell.h 4.1 %G% */
#define TABSIZE (int)(400000/(1<<SHIFT))
int *tab
; /*honeywell loader deficiency*/
#define Tolower(c) (isupper(c)?tolower(c):c) /* ugh!!! */
#define TABSIZE 25000 /*(int)(400000/(1<<shift))--pdp11 compiler deficiency*/
#define NP (sizeof(p)/sizeof(p[0]))
* 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.
prime(argc
, argv
) register char **argv
;
if ((tab
= (int *)calloc(sizeof(*tab
), TABSIZE
)) == NULL
)
if ((f
= fopen(argv
[1], "ri")) == NULL
)
if (fread((char *)tab
, sizeof(*tab
), TABSIZE
, f
) != TABSIZE
)
h
= *(lp
= pow2
[i
]) = 1<<14;
h
= *++lp
= (h
<<7) % p
[i
];
#define get(h) (tab[h>>SHIFT]&(1<<((int)h&((1<<SHIFT)-1))))
#define set(h) tab[h>>SHIFT] |= 1<<((int)h&((1<<SHIFT)-1))