Use similarity for lenient?
Closed this issue · 4 comments
https://github.com/zeke/similarity
Better algorithm
It's not really the same thing. The lenient mode works by detecting if the entered word is close to a valid one on the actual keyboard while modules like similarity
work by how close it is general.
The current lenient is not using any proper algorithm and is implemented naively. lenient should be done using a proper algorithm such as Levenshtein distance.
The current one is pretty naive yes, but still better than using the wrong algorithm. The "proper" algorithm is relative to what you're doing. Here we want to match whether the user mistyped a character on the keyboard by checking if any of the characters around it would have spelled it. Levenshtein is actually more naive in this case as it only lets you know how distance the word is using any character.
Would be happy to see the current algorithm improved, but should be done correctly.
I agree, but using a "proper" algorithm here would be very hard. "autocorrect" and "google suggest" are actually using many different algorithms (including Levenshtein distance) so that they can work reasonably well.