benhoyt / pybktree

Python BK-tree data structure to allow fast querying of "close" matches
MIT License
169 stars 22 forks source link

Levenshtein distance #2

Closed rabbithui closed 6 years ago

rabbithui commented 6 years ago

@benhoyt hi,what should i do if i want to use levenshtein distance?

benhoyt commented 6 years ago

Hi @rabbithui, you can plug in any Levenshtein-distance function as the first argument to BKTree() when you initialize it. There are plenty of edit-distance and Levenshtein libraries around for Python, so just use Google to find something worthwhile. Here's one place, or you could find a well-tested PyPI library.

And actually, just the other day I created a Python Gist to calculate edit distance. Not the most efficient, but it does the job! https://gist.github.com/benhoyt/3152d3cb5762ad1b9d6aa21bcf142969