wolfgarbe / SymSpell

SymSpell: 1 million times faster spelling correction & fuzzy search through Symmetric Delete spelling correction algorithm
https://seekstorm.com/blog/1000x-spelling-correction/
MIT License
3.12k stars 284 forks source link

OCR spelling mistakes #136

Open statzhero opened 11 months ago

statzhero commented 11 months ago

What is the recommended practice for OCR typos that come from say poor kerning? Examples below.

mformation --> information wntmg --> writing

The problem I have is that SymSpell lookup_compound seems to suggest other words such as "formation" or "with a" instead of the correct terms.

Apologies if this is not the right place to ask.

wolfgarbe commented 11 months ago

Symspell takes two factors into account when ranking correction candidates:

  1. the Damerau-Levenshtein edit distance between the misspelled term and the correction candidates (smaller edit distance wins)
  2. the term frequency of the correction candidate (the most frequent word wins)

Symspell does not take into account:

  1. the context (neigbouring words)
  2. how close on the keyboard the misspelled and correct characters are
  3. how phonetically close the misspelled and correct characters are
  4. how optically close the misspelled and correct characters are (e.g. for OCR)

Using those factors with weighted Damerau-Levenshtein edit distance for the ranking of correction candidates could significantly improve correction quality. But the purpose of SymSpell was just to demonstrate the symmetric-delete algorithm and its speed advantage, but not to provide a turn-key spelling correction. But there is a SymSpell implementation with weighted Damerau-Levenshtein edit distance / keyboard-distance which probably could be used to improve correction quality for OCR

statzhero commented 11 months ago

Thank you! I guess I was hoping someone already made a “low tech” solution in the form of a dictionary for all the kerning and ligature issues.