How to Write a Spelling Corrector (2007)
norvig.com
norvig.com
Amusingly half the comments from the first time it was posted (2007) are about how the post is a dupe… https://news.ycombinator.com/item?id=42587
Another brilliant one is PGs “a plan for Spam”: http://www.paulgraham.com/spam.html
(My old team used that technique, though not in Python, many years ago. In modern times, for web clients, I'd export the work to the browser - a full dictionary in the above form is something maybe 200KB, if I remember correctly.)
I should start taking notes to see if I can work out a pattern.
The only novel thing our algorithm contained was a trie-traversal algorithm that found all words approximately within a particular edit distance of the source word in one pass. It separately found words with similar sound and scored by a heuristic of both, but that's fairly standard.
It was also clear that Google was doing something far more impressive on their servers, as it came up with spelling corrections that others didn't and would even suggest corrections that took into account the rest of the search. It's a shame that they've never (to my knowledge) released that technology for others to use. It's possible, of course, that the underlying text model is too large to easily share.
One thing I do that confuses them is putting in extra letters I think should probably be in there. Like 'pherosious' instead of 'ferocious' (Firefox recommends 'heterosporous' - because that's closer!).
That, to me, is surprising in a potentially interesting way. Knowing that an expert like Norvig might still take hours to write such a seemingly simple program suggests the problem is harder than it appears in retrospect.
The program is simple once you know its shape, but there may have been quite some time spent in consideration of how it should work or the details of the edit distance. Also, most programmers overestimate how fast they can write something, and there are plenty of claims that studies show that programmers average only ten lines a day of code.
It doesn't mean the problem is necessarily hard or that it needed to be for it to take time. And flights can be tiring and distracting.