Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use similarity for lenient? #6

Closed
stevemao opened this issue Jun 25, 2015 · 4 comments
Closed

Use similarity for lenient? #6

stevemao opened this issue Jun 25, 2015 · 4 comments

Comments

@stevemao
Copy link

https://github.com/zeke/similarity

Better algorithm

@sindresorhus
Copy link
Owner

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.

@stevemao
Copy link
Author

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.

@sindresorhus
Copy link
Owner

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.

@stevemao
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants