ztane/python-Levenshtein

Levenshtein distance to convert one sentence into another sentence

Opened this issue · 0 comments

Is it possible to get the Levensten distance between two strings, i.e. at the word level and not at the char level? The current behavour is as follows:

  sent1 = "The shy creatures avoid human interactions."
  sent2 = "The foxes are shy."
  nltk.edit_distance(nltk.word_tokenize(sent1), nltk.word_tokenize(sent2))
  5
  Levenshtein.editops(sent1, sent2)
  [('delete', 4, 4), ('delete', 5, 4), ('delete', 6, 4), ('delete', 7, 4), ('delete', 8, 4), ('delete', 9, 4), ('delete', 10, 4), ('delete', 11, 4), ('replace', 12, 4), ('replace', 13, 5), ('replace', 14, 6), ('delete', 19, 11), ('delete', 20, 11), ('delete', 21, 11), ('delete', 22, 11), ('delete', 23, 11), ('delete', 24, 11), ('delete', 25, 11), ('delete', 26, 11), ('delete', 27, 11), ('delete', 28, 11), ('delete', 29, 11), ('delete', 30, 11), ('delete', 31, 11), ('delete', 32, 11), ('delete', 33, 11), ('delete', 35, 12), ('delete', 36, 12), ('replace', 37, 12), ('replace', 38, 13), ('replace', 39, 14), ('replace', 40, 15), ('replace', 41, 16)]

Can Levenshtein.editops return the 5 operations needed to convert s1 to s2?