diff options
| author | yum <yum.food.vr@gmail.com> | 2022-11-10 21:21:07 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2022-11-10 21:21:07 -0800 |
| commit | 772b44806a5f5da11cca74c99b59c3cf7d5ceae5 (patch) | |
| tree | aba2f690b4be58aaa4c0c0f26443ba5085deca63 /string_matcher.py | |
| parent | 2efc87a7180ec6e92127d22d1a3eb8c44fd392db (diff) | |
License scrub
Begin auditing dependencies' licenses.
Diffstat (limited to 'string_matcher.py')
| -rw-r--r-- | string_matcher.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/string_matcher.py b/string_matcher.py index f3284e9..cf11133 100644 --- a/string_matcher.py +++ b/string_matcher.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 -# python3 -m pip install python-Levenshtein -from Levenshtein import distance as levenshtein_distance +# python3 -m pip install editdistance +# License: MIT. +import editdistance import typing @@ -26,7 +27,7 @@ def matchStringList(old_words: typing.List[str], new_slice = new_words[i:i + window_size] cur_d = 0 for j in range(0, window_size): - cur_d += levenshtein_distance(old_slice[j], new_slice[j]) + cur_d += editdistance.eval(old_slice[j], new_slice[j]) if cur_d < best_match_d: best_match_i = i best_match_d = cur_d @@ -76,7 +77,7 @@ def matchStrings(old_text: str, new_text: str, window_size = 3) -> str: for j in range(0, 1 + len(new_text) - window_size): new_slice = new_text[j:j + window_size] - cur_d = levenshtein_distance(old_slice, new_slice) + cur_d = editdistance.eval(old_slice, new_slice) if cur_d <= best_match_d: best_match_i = i best_match_j = j |
