Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. def recommendation(word):
  2. n = 3
  3. # n means 'n'-grams, here I use 3 as an example
  4. spellings_new = [w for w in spellings if (w[0] == word[0])]
  5. dists = [jaccard_distance(set(w), set(word)) for w in spellings_new]
  6. return spellings_new[dists.index(min(dists))]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement