Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. def ConvertMisspellingInList(words,correct_word_list):
  2. """
  3. words : str型  "App1e Pie” など修正する必要のある文字列
  4. correct_word_list : list型 正しい単語のリスト
  5. """
  6.  
  7. res = []
  8. for word in words.split(" "):
  9.  
  10.  
  11. tmp = [Levenshtein.distance(word, str(string)) for string in correct_word_list]
  12. res.append(correct_word_list[tmp.index(min(tmp))])
  13.  
  14.  
  15. return " ".join(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement