37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
d[i, j-1] + 1, # Insertion
d[i-1, j-1] + nCost, # Substitution
)
if i and j and s1[i] == s2[j-1] and s1[i-1] == s2[j]:
d[i, j] = min(d[i, j], d[i-2, j-2] + nCost) # Transposition
return d[nLen1-1, nLen2-1]
# Method: Remove Useless Chars
_dVovels = {
'a': '', 'e': '', 'i': '', 'o': '', 'u': '', 'y': '',
'à': '', 'é': '', 'î': '', 'ô': '', 'û': '', 'ÿ': '',
'â': '', 'è': '', 'ï': '', 'ö': '', 'ù': '', 'ŷ': '',
|
>
>
>
>
>
>
>
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
d[i, j-1] + 1, # Insertion
d[i-1, j-1] + nCost, # Substitution
)
if i and j and s1[i] == s2[j-1] and s1[i-1] == s2[j]:
d[i, j] = min(d[i, j], d[i-2, j-2] + nCost) # Transposition
return d[nLen1-1, nLen2-1]
def showDistance (s1, s2):
s1b = cleanWord(s1);
s2b = cleanWord(s2);
print(f"Distance: {s1} / {s2} = {distanceDamerauLevenshtein(s1, s2)}")
print(f"Distance: {s1b} / {s2b} = {distanceDamerauLevenshtein(s1b, s2b)}")
# Method: Remove Useless Chars
_dVovels = {
'a': '', 'e': '', 'i': '', 'o': '', 'u': '', 'y': '',
'à': '', 'é': '', 'î': '', 'ô': '', 'û': '', 'ÿ': '',
'â': '', 'è': '', 'ï': '', 'ö': '', 'ù': '', 'ŷ': '',
|