bloom filter

spellchecker

5,000,000 bit array bloom filter (625KB)

Each word is passed through 7 different hash functions and the corresponding locations in the bit array is checked. If any bit is not set, the word doesn't exist and is a mispelled word. Array size is 625KB instead of the ~8.5MB it takes to store 479,000 English words.

The 7 hash functions are the same algorithm seeded 7 different ways: starting from a fixed seed, fold in each character's code (hash = hash·33 + charCode), then take the result mod 5,000,000. Seeds: 10939, 60763, 102533, 90641, 7673, 45319, 77951.

Word list sourced from dwyl/english-words, plus hand-curated additions for short interjections, contractions, and a handful of famously long words it doesn't include. A "not a valid word" result just means the word isn't in this list, not that it's necessarily wrong.