Levenshtein
http://www.coli.uni-saarland.de/courses/LT1/2011/slides/Python-Levenshtein.html#Levenshtein-inverse
也是replace,insert,delete,equal,但是粒度比difflib小,是一个字母的变化,
稍微改了一下:
for flag, sp, dp in Levenshtein.editops(row[0], row[1]):
if flag == 'insert':
print '_ -> %s' % row[1][dp]
elif flag == 'delete':
print '%s -> ' % row[0][sp]
elif flag == 'replace':
print '%s -> %s' % (row[0][sp], row[1][dp])
else:
print flag
python 自带的
difflib
替换和交换都作为replace
所以显示的编辑距离有:replace,insert,delete,equal