Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Can someone point me to data or research on the patterns of mistyping on a keyboard? For instance, I've noticed that google will sometimes auto-correct a word that I've mistyped because my hand was out of position and each key was shifted one to the right. I'm also interested words where there is a mis-coordination between both hands, such as teh, and any other misspellings that are artifacts of keyboards and manual dexterity.

We're looking at some user-friendly auto-correct functions, and I want some data to help our team get an overview of the landscape and decide what we will and will not handle.

share|improve this question

1 Answer 1

Google uses a Bayesian network to determine if you've misspelled a word or not, and what the most likely to be correct word. You can use something like this: http://code.google.com/p/google-api-spelling-java/ to take advantage of google's work for you.

If you want to find out how google does it, check out this question: http://stackoverflow.com/questions/307291/how-does-the-google-did-you-mean-algorithm-work

Another option you can consider is levenshtein distance, it's a measurement of how far apart words are. Here is how to use it in PHP: http://php.net/manual/en/function.levenshtein.php

You can also use Metaphone which translates the string into a phonetic representation which can be used to compare words. This works best with english words as it was designed to use english phonemes. Metaphones isn't very useful for typos, since they'll not sound similar, but it will help discover the correct spellings for words when people 'sound them out.' Here's how to use it in PHP: http://php.net/manual/en/function.metaphone.php

share|improve this answer
Could you explain why "levenshtein works best with english words"? –  blubb Aug 30 '11 at 17:29
I was thinking of metaphone and soundex, not levenshtein. –  Malfist Aug 30 '11 at 17:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.