Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ConvertMisspellingInList(words,correct_word_list):
- """
- words : str型 "App1e Pie” など修正する必要のある文字列
- correct_word_list : list型 正しい単語のリスト
- """
- res = []
- for word in words.split(" "):
- tmp = [Levenshtein.distance(word, str(string)) for string in correct_word_list]
- res.append(correct_word_list[tmp.index(min(tmp))])
- return " ".join(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement