Is there a faster (less precise) algorithm than Le

2020-03-04 05:55发布

I want to run the Levenshtein, but WAY faster because it's real time application that I'm building. It can terminate once the distance is greater than 10.

3条回答
男人必须洒脱
2楼-- · 2020-03-04 06:38

Judging from comments, people seem to be pretty happy with Sift3.

http://sift.codeplex.com

查看更多
欢心
3楼-- · 2020-03-04 06:39

If you want to compare UTF-8 contents use sift4:

https://siderite.dev/blog/super-fast-and-accurate-string-distance.html

Also I prepared a jsPerf which shows the performance difference between those libraries: http://jsperf.com/levenshtein-perf

查看更多
疯言疯语
4楼-- · 2020-03-04 06:46

The Levenshtein distance metric allows addition, deletion or substitution operations. If you're looking for a faster but less precise metric you can use the longest common subsequence (allows only addition and deletion) or even the Hamming distance (allows only substitution).

However, I recommend that you try to optimize your Levenshtein distance algorithm instead as it gives the best results.

查看更多
登录 后发表回答