Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

Autocorrect is a computer science tool that helps turn noisy typing into the words a user probably meant. It matters because small errors are common on phone keyboards, where fingers hit nearby keys and people type quickly. A good autocorrect system must balance spelling rules, keyboard geometry, word frequency, and the context of the sentence.

The goal is not just to find a real word, but to find the most likely intended word.

Key Facts

  • Autocorrect usually ranks candidates by combining edit distance, word frequency, keyboard proximity, and context.
  • Edit distance counts the minimum number of insertions, deletions, substitutions, or swaps needed to change one string into another.
  • A simple scoring idea is best word = argmax P(word | typed input).
  • Bayes' rule can model correction as P(word | input) = P(input | word)P(word) / P(input).
  • Language models estimate context with probabilities such as P(next word | previous words).
  • Keyboard distance helps because mistyped letters are often near the intended letters, such as g instead of h.

Vocabulary

Autocorrect
Autocorrect is software that detects likely typing errors and suggests or applies a more probable word.
Edit distance
Edit distance is the number of small changes needed to transform one word into another.
Candidate word
A candidate word is a possible correction that the system considers for a typed input.
Language model
A language model is a system that estimates how likely words or sequences of words are in a language.
Probability score
A probability score is a numerical estimate of how likely a correction is compared with other choices.

Common Mistakes to Avoid

  • Choosing the word with the smallest edit distance only, because a close spelling match may be rare or wrong in context.
  • Ignoring context, because the best correction for a word can change depending on nearby words in the sentence.
  • Assuming autocorrect always uses a dictionary lookup, because modern systems often use statistical models and learned patterns from large text data.
  • Treating every typo as equally likely, because keyboard layout makes some mistakes more probable than others, such as tapping a neighboring key.

Practice Questions

  1. 1 The typed word is teh. Candidate corrections have scores: the = 0.72, ten = 0.10, tech = 0.07, tea = 0.04. Which correction should autocorrect choose if it selects the highest score?
  2. 2 A simple autocorrect score is score = 0.6(word frequency) + 0.4(keyboard similarity). For cat, frequency = 0.70 and similarity = 0.80. For car, frequency = 0.60 and similarity = 0.95. Which word gets the higher score?
  3. 3 A user types I will meat you at noon. Explain why an autocorrect system should use sentence context before changing meat to meet.