Interesting that the shortest (and among the most readable) is the 15-line version written in old-school AWK:
<a href="http://pacman.blog.br/wiki/index.php?title=Um_Corretor_Ortográfico_em_GAWK" rel="nofollow">http://pacman.blog.br/wiki/index.php?title=Um_Corretor_Ortog...</a><p>A surprise is that the Perl implementation weighs in at 63 lines. I would have expected much less. I expect a much shorter version is possible, relying on idiomatic constructs at the expense of readability.
I'm no Python expert, but I liked doing this in Haskell:<p><a href="http://www.partario.com/blog/2009/10/a-spelling-corrector-in-haskell.html" rel="nofollow">http://www.partario.com/blog/2009/10/a-spelling-corrector-in...</a><p><a href="https://github.com/timrobinson/spell-correct/blob/master/Correct.hs" rel="nofollow">https://github.com/timrobinson/spell-correct/blob/master/Cor...</a>
I have seen this one before somewhere, and what amazes me is that how you can solve problems without a hassle if you get the "trick" right. Another case I read was that Google use(at least used) two vectors(each consists of many 0s and 1s, which in turn represent whether the web page has the keyword or not) to represent web pages, and calculate the angle between the vectors to figure out the similarity(a value) between web pages.
Scrolling to the bottom of the article gives you a list of similar implementations in other languages.<p>Very interesting to see how other have tackled this programming problem.
In PHP, you can use the levenshtein() function.<p><a href="http://php.net/manual/en/function.levenshtein.php" rel="nofollow">http://php.net/manual/en/function.levenshtein.php</a>
If anyone is interested in other applications of this technique, this is a Ruby library I wrote to do sentence tokenization: <a href="https://github.com/SlyShy/Tactful_Tokenizer" rel="nofollow">https://github.com/SlyShy/Tactful_Tokenizer</a>
I found it fascinating that you can actually implement something seemingly so magical in such a small amount of code.<p>I'm down as 22 lines of C#, though to be fair I am cheating vastly and the lines are huge :)<p><a href="http://www.codegrunt.co.uk/2010/11/02/C-Sharp-Norvig-Spelling-Corrector.html" rel="nofollow">http://www.codegrunt.co.uk/2010/11/02/C-Sharp-Norvig-Spellin...</a><p>C# does offer some nice features to give you some succinctness but there's no getting away from the verboseness of a java-like language.