Skip to content

Instantly share code, notes, and snippets.

@Sanix-Darker
Last active October 7, 2019 10:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sanix-Darker/46840a9587d4a29da948d0313128798b to your computer and use it in GitHub Desktop.
Save Sanix-Darker/46840a9587d4a29da948d0313128798b to your computer and use it in GitHub Desktop.
[PYTHON]Levenshtein_distance
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