1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
"""
List of similar chars
useful for suggestion mechanism
"""
import re
dDistanceBetweenChars = {
"a": {},
"e": {"é": 0.5},
"é": {"e": 0.5},
"i": {"y": 0.2},
"o": {},
|
<
<
|
1
2
3
4
5
6
7
8
9
10
11
12
|
"""
List of similar chars
useful for suggestion mechanism
"""
dDistanceBetweenChars = {
"a": {},
"e": {"é": 0.5},
"é": {"e": 0.5},
"i": {"y": 0.2},
"o": {},
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
"w": {"v": 0.1},
"x": {"c": 0.5, "k": 0.5, "q": 0.5, "s": 0.5},
"z": {"s": 0.5}
}
def distanceBetweenChars (c1, c2):
if c1 == c2:
return 0
if c1 not in dDistanceBetweenChars:
return 1
return dDistanceBetweenChars[c1].get(c2, 1)
|
>
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
"w": {"v": 0.1},
"x": {"c": 0.5, "k": 0.5, "q": 0.5, "s": 0.5},
"z": {"s": 0.5}
}
def distanceBetweenChars (c1, c2):
"returns a float between 0 and 1"
if c1 == c2:
return 0
if c1 not in dDistanceBetweenChars:
return 1
return dDistanceBetweenChars[c1].get(c2, 1)
|