我有两个字符串:
>>> a= '@ROAD INC'
>>> b = 'WYETH'
>>> Levenshtein.ratio(a, b)
0.0
现在我理解它背后的计算,但不是直觉:
>>> ldist = sum([2 for item in Levenshtein.editops(a,b) if item[0] == 'replace'])
+ sum([1 for item in Levenshtein.editops(a,b) if item[0] != 'replace'])
>>> ln = len(a) + len(b)
>>> ldist - ln
0
结果不是直观的吗?不应该将Levenshtein.ratio降低为字符串匹配而不是完全字符串差异吗?