Notes

Spell Correction

Type "recieve" into a search box and you still expect the right results back. A model has no such instinct: that misspelling is a string it has never seen, a fresh vocabulary entry with no learned meaning attached. Spell correction is the normalisation step that maps surface typos back onto words the rest of the pipeline already knows.

How a corrector chooses
Two signals decide between candidates — how close a candidate is to what was typed, and how plausible it is as the intended word.

  • Edit distance: Levenshtein distance counts the insertions, deletions, substitutions and transpositions separating two strings, and most genuine typos sit one or two edits from the target.
  • Noisy-channel scoring: treat the typed form as a corrupted version of an intended word and pick the candidate that maximises the intended word's prior probability times the likelihood of that specific slip.
  • Context: "their" for "there" is spelled perfectly, so only a language model over the neighbouring words can catch it. These real-word errors are the harder half of the problem.

What it buys and what it breaks
Correction keeps user-generated text — queries, reviews, support tickets — from fragmenting into near-duplicate tokens that dilute counts in bag-of-words and TF-IDF representations, and it rescues retrieval matches that would otherwise be missed. SymSpell and Hunspell do it at scale; pyspellchecker and spaCy extensions wrap it for Python pipelines. Pushed too hard it does damage: an aggressive corrector rewrites surnames, product codes and domain jargon into ordinary words, destroying the exact tokens an extractor was looking for. Subword tokenizers absorb mild misspellings on their own, so correction earns its place where counts are consumed directly, or where the text will be shown back to a person.

Spell correction maps a misspelled token back to a known vocabulary item, scoring dictionary candidates within a small edit distance of the typed string and ranking them by word frequency or by a language model over the neighbouring words. It matters because an uncorrected typo is an out-of-vocabulary token carrying no learned representation: counts fragment across near-duplicates and retrieval misses matches. Real-word errors such as "their" for "there" need context, not distance.

A proofreader does not just notice that "recieve" is wrong — they know you meant "receive" and carry on reading. Software needs that favour done for it before it can make sense of what people type.

Spell correction takes a word that isn't in its dictionary, finds the real words closest to it, and picks whichever fits best. To a computer, "receive" and "recieve" are two unrelated things, so a typo in a search box can quietly cost you the result you wanted. Fixing it first means everything downstream sees one familiar word. The sneaky cases are spelled perfectly but still wrong — "their" instead of "there" — and only the rest of the sentence gives those away.