Last active
October 7, 2019 10:54
-
-
Save Sanix-Darker/46840a9587d4a29da948d0313128798b to your computer and use it in GitHub Desktop.
[PYTHON]Levenshtein_distance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import difflib | |
print("Levenshtein distance implementation !") | |
_str = 'appel' | |
difflib.get_close_matches('appel', ['ape', 'apple', 'peach', 'puppy'], n=2) | |
# returns ['apple', 'ape'] | |
# difflib.get_close_matches finds the best "good enough" matches. | |
# Here, first argument is being matched against the second one. | |
# We can also supply optional argument n which specifies maximum number of matches to be returned. | |
# Another available keyword argument cutoff (defaults to 0.6) can be set to change threshold for score of matched strings. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment