„similarity.py“ ändern
This commit is contained in:
parent
53407feb35
commit
6c79ba9379
@ -60,10 +60,12 @@ def edit_distance(word_1: str, word_2: str, to_same_case: bool = True) -> int:
|
||||
|
||||
# not in the beginning or the end
|
||||
if i > 0 and i < len(word_1):
|
||||
# previous char is same and current char of word_1 is same as next char of word_2
|
||||
# -> fill current char of word_2 between last and next char of word_1
|
||||
# e.g. word_1[i-1] = "M" ; word_1[i] = "R"
|
||||
# word_2[i-1] = "M" ; word_1[i] = "A" ; word_2[i+1] = "R"
|
||||
"""
|
||||
previous char is same and current char of word_1 is same as next char of word_2
|
||||
-> fill current char of word_2 between last and next char of word_1
|
||||
e.g. word_1[i-1] = "M" ; word_1[i] = "R"
|
||||
word_2[i-1] = "M" ; word_1[i] = "A" ; word_2[i+1] = "R"
|
||||
"""
|
||||
if word_1[i-1] == word_2[i-1] and word_1[i] == word_2[i+1]:
|
||||
word_1.insert(i, word_2[i])
|
||||
count += 1
|
||||
|
Loading…
Reference in New Issue
Block a user