Algorithms, visualizedExhibit 18

How does autocorrect know what you meant?

It combines three clues: which real words are one slip away from what you typed, how common each of those words is, and the words around it. This page runs the first two in your browser. It gets most single slips right, and it shows you exactly where it fails.

Try it: type a misspelling

Type one misspelled word, for example tge, wierd or juce. The page lists the known words that are one or two slips away and picks the most common one.

Our corrector picks
…
Strings one slip away
…

Word list and "how common" numbers: the 29,152 words our test used, taken from the 30,000 most common English words in the wordfreq project (Robyn Speer, data under CC BY-SA 4.0), shown as uses per million words. This corrector has no idea of context, so it will pick June for juce. A phone keyboard also uses where your finger landed and the words before.

The video for this exhibit comes out on YouTube on Friday 8 January. Subscribe so you don’t miss it

One slip away

In 1964, computer scientist Fred Damerau found that more than 80 percent of the spelling errors he studied were a single slip: one letter missing, one extra, one wrong, or two swapped. So a spelling corrector starts by undoing every possible slip. For the three letters tge that makes 182 different strings, and only 11 of them are in our word list.

The common word wins

Next it has to choose. The simplest clue is how common each word is: in everyday English, the is used about 250 times as often as age, so the wins. On a phone the spelling clue is sharper, because the keyboard knows where your finger landed: G sits right next to H, so hitting G when you wanted H is an easy slip. A touch keyboard treats every tap as a blurry spot, not one exact key.

What we measured

We tested our corrector on 670 real misspellings collected by researchers, each with the word the writer meant. Spelling alone, guessing when several words were equally close, was right 66% of the time. Adding how common each word is took it to 73%. A simple keyboard clue did not help (72%), which makes sense: most of these words were written by hand by people unsure of the spelling, so this test cannot say how much keyboard clues help real typing.

Where it fails: context

Someone wrote juce and meant juice. The closest words include June, juice and Jude, and June is the most common, so our corrector picked June. Our two clues cannot fix that. A language model can: it scores how likely each word is, given the words before it. After a glass of orange, juice is far more likely than June. Phone keyboards have used simple language models for years, and in 2023 Apple said its keyboard had switched to a transformer model running on the phone.

Frequently asked questions

Why does autocorrect change words that were right?

It picks the most likely word, not the one you typed. If your word is rare, or not in its word list, a more common word that is one slip away can win. Keyboards learn words you keep typing, and you can usually add a word yourself.

What is edit distance?

The number of single slips (a missing, extra, wrong or swapped letter) needed to turn one string into another. Most spelling correctors start by looking for real words at edit distance one.

Does autocorrect use AI?

Modern phone keyboards use language models that predict likely words from context. Apple said in 2023 that the iPhone keyboard uses a transformer language model that runs on the device.

Sources

Last updated

Keep exploring