fix levenshtein() for empty strings

This commit is contained in:
urlbot
2014-09-30 16:48:17 +02:00
parent 75dd68733f
commit ca715ca0f8

View File

@@ -47,6 +47,7 @@ def levenshtein(a, b, return_table=False):
# initialisize a table with 0, but the 0-rows/cols with their index
d = [[ (i if 0 == j else j if 0 == i else 0) for j in range(len(b)+1) ] for i in range(len(a)+1) ]
i = j = 0
for i in range(1, len(a)+1):
for j in range(1, len(b)+1):
if a[i-1] == b[j-1]: