Spelling correction is the task of detecting misspelled words in text and replacing them with the most likely intended word. Within Speech & language AI, it is one of the oldest and most widely deployed language technologies, found in word processors, search engines, mobile keyboards and as a preprocessing step for downstream models. Familiar product names for it include spell checker and autocorrect.
The task has two parts: error detection, which decides that a word is wrong, and candidate correction, which proposes and ranks replacements. Modern systems combine a lexicon, a model of typical typing errors and a language model that judges context.
How spelling correction finds the intended word
Most spelling correctors follow the noisy channel model. The system assumes that the writer intended a correct word w, and that a noisy process turned it into the observed string x. The corrector chooses the w that maximizes P(w) multiplied by P(x given w), where P(w) is the language model probability and P(x given w) is the error model probability.
Candidate generation usually enumerates words within a small edit distance of the observed string. Damerau-Levenshtein distance counts insertions, deletions, substitutions and transpositions of adjacent letters. Research on typing errors shows that most misspellings lie within edit distance 1 or 2 of the intended word, so a search radius of two covers the large majority of cases.
The table below lists the four basic edit operations and what each captures.
| Operation | Example error | Intended word | Typical cause |
|---|---|---|---|
| Substitution | recieve | receive | Keyboard neighbor or vowel confusion |
| Insertion | untill | until | Doubled key press |
| Deletion | acommodate | accommodate | Missed key or uncertain spelling |
| Transposition | teh | the | Fingers out of sequence |
Non-word errors and real-word errors
Spelling errors fall into two classes with very different difficulty. A non-word error produces a string that is not in the dictionary, such as “graffe” for “giraffe”, so detection is a simple lexicon lookup. A real-word error produces another valid word, such as “form” for “from” or “their” for “there”, and can only be detected through context.
Real-word errors are estimated to account for a substantial share of errors in edited text, often cited at a quarter to a third or more. They require the corrector to treat every word as a possible error and to compare the sentence probability with and without each candidate replacement.
| Error class | Detection method | Difficulty | Example |
|---|---|---|---|
| Non-word error | Dictionary lookup | Low | “wierd” for “weird” |
| Real-word error | Context model | High | “peace of cake” |
| Cognitive error | Context and phonetics | High | “seperate” for “separate” |
| Split or merge error | Segmentation search | Medium | “infact” for “in fact” |
Approaches from rules to neural models
Spelling correction has moved from hand-built dictionaries to statistical and neural methods. Each generation remains in use because the methods differ in speed, memory and accuracy.
Dictionary-based checkers such as Hunspell use a lexicon with morphological rules, which suits highly inflected languages where listing every form is impractical. Statistical correctors add N-gram language models and error models trained on logs of real corrections. Phonetic algorithms such as Soundex and Metaphone help with errors made by writers who spell by sound.
Neural correctors treat the task as sequence-to-sequence transformation, often at the character or subword level, and large language models can correct spelling as part of broader editing. Neural models handle real-word errors well but are slower and may over-correct rare names or technical terms.
| Approach | Context use | Speed | Best suited for |
|---|---|---|---|
| Lexicon and edit distance | None | Very fast | Basic non-word checking |
| Noisy channel with N-grams | Local window | Fast | Search queries, keyboards |
| Neural sequence model | Full sentence | Moderate | Real-word errors, noisy text |
| Large language model | Document level | Slow | Editing assistance, rewriting |
Spelling correction in search, keyboards and speech pipelines
Deployment context determines how aggressive a corrector should be. A search engine can show “Did you mean” suggestions and learn from which suggestions users accept, while a mobile keyboard must decide in milliseconds and should avoid replacing intentional words.
Query spelling correction relies heavily on query logs, because user reformulations reveal intended spellings for product names and new terms that no dictionary contains. Keyboard autocorrect adds a touch model that weights keys near the actual tap point. In OCR and speech-to-text pipelines, correction must address recognition errors that differ from human typing errors, such as “rn” read as “m”.
Spelling correction is narrower than grammatical error correction, which also fixes agreement, word order and article use, and narrower than text normalization, which converts abbreviations and numbers into standard written forms.
Limitations and failure modes
The most visible failure of spelling correction is the confident wrong replacement. Because correctors prefer frequent words, they push rare but correct words toward common ones.
- Proper names and jargon are often flagged or replaced because they are missing from the lexicon.
- Over-correction changes valid slang, dialect or deliberate stylistic spelling.
- Low-resource languages lack the large corpora needed for strong language models.
- Code-switching text mixes languages and confuses single-language dictionaries.
- Evaluation gaps: accuracy on synthetic errors overstates performance on real user errors.
Good systems mitigate these issues with user dictionaries, domain lexicons and confidence thresholds, so that low-confidence corrections are offered as suggestions instead of being applied automatically.
Evaluation should separate detection recall, the share of real errors flagged, from correction accuracy, the share of flagged errors fixed with the right word. A third measure, the false alarm rate on correct words, matters most to users, because every unwanted change to a correct word erodes trust faster than a missed error does. Test sets should contain naturally occurring errors collected from the target domain rather than only synthetic edits.
In everyday language
Spelling correction is the software that notices a misspelled word and fixes it. It works a bit like a careful friend reading over your shoulder. It sees “teh” and knows you meant “the”.
To choose the right fix, it asks two questions. Which real words look close to what you typed? Which of those words makes sense in the sentence? The best answer wins. It is helpful, but it can make mistakes, especially with names and unusual words.
Seen in the real world
An online pharmacy notices that many customers search for medicines with misspellings such as “ibuprofin” or “amoxicilin”, and about 12 percent of searches return no results. The search team builds a query spelling corrector that combines a domain lexicon of drug names with an error model trained on past queries that users later reformulated.
For each query, the system generates candidates within edit distance 2, ranks them with a language model built from the product catalog, and applies the correction automatically only above a high confidence threshold. Below it, the page shows a “Did you mean” suggestion. After launch, zero-result searches fall to about 4 percent, and pharmacists review a weekly list of corrections to make sure that similar drug names are never silently swapped.