1000x Faster Spelling Correction: Source Code released
blog.faroo.com
blog.faroo.com
Added: I'd guess the newer Norvig corrector is still slower, though it is more accurate (taking into account probabilities of different typos). There's a curiosity not mentioned in his article, that the new algorithm computes a very slightly different set of candidates. I only noticed the difference when I got around to checking these sets against each other for all the words in a sample document -- I'd meant them to be the same. Might be fun to check the OP's code this way too.
We can build a spelling corrector which is accurate most of the time and much faster than the Faroo implementation:
def corrections_for(word)
return [word]
end
P.S. I added a gist here with some reformatting because I found it hard to read the code on the author's site:https://gist.github.com/fj/8393399
The raw source is here:
https://gist.github.com/fj/8393399/raw/7d4acd14db21dd0c7d802...
Compared to that, they have the exact same results. What they present is a faster way to find all dictionary words with edit distance <= 2 from a given word.
Thank you. Funny enough, that gist has the same problem on my screen (too much whitespace on either side of a box that I need to horrizontally scroll) - it's just not as bad.
Here's how the site shows up for me: http://imgur.com/CjXRHBC
Grumble.
I'm also not sure how they benchmarked the other solution, as that clearly isn't optimised for runtime but for readability (it's a nice bit of code).
Roughly speaking, they pre-compute some of the character substitutions done in traditional algorithm, and add it to the dictionary.
I do wonder what happened to normal C# style here though. Had a hard time reading this, because 'suggestItem' or 'editItem' etc. doesn't _look_ like a type/class. A single uppercase/lowercase change and I stumbled a couple of times.
But the greater field I'm working in doesn't hand you random OCR and that's it. Most projects here contain a way for typists to correct recognition mistakes or complete the missing pieces of information on a document. For that (-> human typist, often you have a database with valid/expected values for fields) transpositions aren't rare at all.
This is not new or not previously known. Sensational title.
https://github.com/ahmetaa/leblebi/blob/master/src/main/java...
I'd prefer to see research in this direction rather than speed improvement on a method we all know doesn't really work. Because your typo is close to one entry (an existing word) in a list (the dictionary) that you maybe never heard of before doesn't mean you intended to type this.
This is the Dart version: https://github.com/ahmetaa/dart-spell
Would we see the same performance increase in practice?