Data, Maps, Usability, and Performance

Typos Script to Generate Misspellings

Last updated on November 20, 2012 in Development, SEO

SEO Typos Script

I was thinking about misspellings recently and wanted to put together a small PHP script that will generate typos from a given word. The idea is based around typos being generated based on proximity of other letters or numbers next to the correct character on a keyboard. There are other ways to think about misspellings, but it makes sense that most typos occur as a result of a user accidentally pressing the wrong key. So, we just create an array for each key, which has all the surrounding keys, and then use these arrays in a loop which replaces characters in a string with other characters that are close in proximity on the keyboard.

I wanted to do this server side so I wrote the script in PHP. Here is the code:

Later I realized that it would be cool for this to work via JavaScript so I rewrote the loop but the character arrays obviously stayed the same. Check out the the misspelling JavaScript function below:

Finally, here is the online demo of the PHP Typos Generator. A different way to think about misspellings would be to look at commonly misspelled words, lists of typos, and do a search and replace on these words.

Tags: , ,

Facebook Twitter Hacker News Reddit More...