„similarity.py“ ändern

This commit is contained in:
Florian Kaiser 2023-01-10 12:50:24 +01:00
parent 53407feb35
commit 6c79ba9379

View File

@ -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 # not in the beginning or the end
if i > 0 and i < len(word_1): 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 previous char is same and current char of word_1 is same as next char of word_2
# e.g. word_1[i-1] = "M" ; word_1[i] = "R" -> fill current char of word_2 between last and next char of word_1
# word_2[i-1] = "M" ; word_1[i] = "A" ; word_2[i+1] = "R" 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]: if word_1[i-1] == word_2[i-1] and word_1[i] == word_2[i+1]:
word_1.insert(i, word_2[i]) word_1.insert(i, word_2[i])
count += 1 count += 1