3 ms·
I probably have some very old code somewhere I wrote for fun where I modified the Levenhstein edit distance DP algo to take keyboard layout into account. For e
by TacticalCoder 5y ago
I probably have some very old code somewhere I wrote for fun where I modified the Levenhstein edit distance DP algo to take keyboard layout into account. For example if you have "doga", the edit distance with "dogs" and "yoga" is the same. But if you're on an QWERTY or AZERTY keyboard, "dogs" is a much more likely typo than "yoga" for "s" is close to "a" while "y" is nowhere to be seen near the letters you entered. Something like that. So basically by taking the keyboard layout into account suggestions can be ranked more efficiently.
Pretty sure the modification was relatively simply and the algo was still a dynamic programming algo. I probably still have the code somewhere.
EDIT: memory being fuzzy too but as I remember it the Levenshtein edit distance ain't that great for typos for a typo where you invert two characters counts as 2 instead of 1? It's probably overused for it's DP implementation is beautiful...
- skissane 5y ago> memory being fuzzy too but as I remember it the Levenshtein edit distance ain't that great for typos for a typo where you invert two characters counts as 2 instead of 1 In which case you want Damerau–Levenshtein distance instead of Levenshtein distance. Damerau–Levenshtein distance counts swapping adjacent characters as a single editing operation instead of two consecutive operations.
- dekhn 5y agohttps://norvig.com/spell-correct.html https://norvig.com/spell-correct.html