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

Is edits generations, needed after getting exact match? #84

Closed VJAYSLN closed 4 years ago

VJAYSLN commented 4 years ago

Hello @wolfgarbe , I am using symspell for a last couple of months. I am having some queries on your logic. when giving the dictionary word as input with Verbosity::ALL mode, why it goes for checking deletion entry and other functions.? Why it goes for word edits, even though a exact match founded? Is that any motivation behind this?

Code For this:-

if (words.TryGetValue(input, out suggestionCount))
        {
            suggestions.Add(new SuggestItem(input, 0, suggestionCount));
            // early exit - return exact match, unless caller wants all matches
            if (verbosity != Verbosity.All) goto end;
            // goto end;
        }

Thanks in Advance : )

wolfgarbe commented 4 years ago

If you select Verbosity.ALL, then SymSpell.Lookup() will return all possible spelling suggestions within the given maxEditDistance, even if an exact match exists.

For example, if your input is cars, it SymSpell will return both cars and card. You see, the s and d key are neighbors on the keyboard. Even if cars is a valid word, perhaps your intention was to write card, you just hit accidentally the wrong neighboring key.

If you select Verbosity.Top or Verbosity.Closest , then SymSpell.Lookup() will return only the exact match, if an exact match exists.