瀏覽代碼

Bug fix

If one string is empty, the edit-distance is the length of the other
Uri Goren 6 年之前
父節點
當前提交
5f6717fe6d
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      strsimpy/levenshtein.py

+ 1 - 1
strsimpy/levenshtein.py

@@ -33,7 +33,7 @@ class Levenshtein(MetricStringDistance):
         if len(s0) == 0:
             return len(s1)
         if len(s1) == 0:
-            return len(s1)
+            return len(s0)
 
         v0 = [0] * (len(s1) + 1)
         v1 = [0] * (len(s1) + 1)