Created
June 8, 2019 19:11
-
-
Save kylebgorman/baa896af68ef508b6a73264a721d4efa to your computer and use it in GitHub Desktop.
Which English word is most similar to "covfefe"?
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
#!/usr/bin/env python | |
# What's the nearest word (in Levenshtein distance) to "covfefe"? | |
import string | |
# Available from: https://github.com/kylebgorman/EditTransducer | |
import edit_transducer | |
# You probably have this file if you're on Linux or Mac OS X. | |
with open("/usr/share/dict/words") as source: | |
lexicon = [line.rstrip() for line in source] | |
# By limiting it to ASCII letters we'll throw out "'s" words, etc. | |
la = edit_transducer.LevenshteinAutomaton(string.ascii_letters, lexicon) | |
print(la.closest_match("covfefe")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment