14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
'œ': 'oe', 'æ': 'ae',
})
def cleanWord (sWord):
"word simplication before calculating distance between words"
return sWord.lower().translate(_xTransChars).replace("eau", "o").replace("au", "o")
# Similar chars
d1to1 = {
"1": "liîLIÎ",
"2": "zZ",
"3": "eéèêEÉÈÊ",
|
>
>
>
>
>
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
'œ': 'oe', 'æ': 'ae',
})
def cleanWord (sWord):
"word simplication before calculating distance between words"
return sWord.lower().translate(_xTransChars).replace("eau", "o").replace("au", "o")
aVowel = set("aáàâäāeéèêëēiíìîïīoóòôöōuúùûüūyýỳŷÿȳœæAÁÀÂÄĀEÉÈÊËĒIÍÌÎÏĪOÓÒÔÖŌUÚÙÛÜŪYÝỲŶŸȲŒÆ")
aConsonant = set("bcçdfghjklmnñpqrstvwxzBCÇDFGHJKLMNÑPQRSTVWXZ")
aDouble = set("bcçdfjklmnprstzBCÇDFJKLMNPRSTZ") # letters that may be used twice successively
# Similar chars
d1to1 = {
"1": "liîLIÎ",
"2": "zZ",
"3": "eéèêEÉÈÊ",
|
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
d1toX = {
"æ": ("ae",),
"Æ": ("AE",),
"b": ("bb",),
"B": ("BB",),
"c": ("cc", "ss", "qu", "ch"),
"C": ("CC", "SS", "QU", "CH"),
"ç": ("ss", "cc", "qh", "ch"),
"Ç": ("SS", "CC", "QH", "CH"),
"d": ("dd",),
"D": ("DD",),
"f": ("ff", "ph"),
"F": ("FF", "PH"),
"g": ("gu", "ge", "gg", "gh"),
"G": ("GU", "GE", "GG", "GH"),
"i": ("ii",),
"I": ("II",),
"j": ("jj", "dj"),
"J": ("JJ", "DJ"),
"k": ("qu", "ck", "ch", "cu", "kk", "kh"),
"K": ("QU", "CK", "CH", "CU", "KK", "KH"),
"l": ("ll",),
"L": ("LL",),
"m": ("mm", "mn"),
|
<
<
>
>
<
<
|
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
d1toX = {
"æ": ("ae",),
"Æ": ("AE",),
"b": ("bb",),
"B": ("BB",),
"c": ("cc", "ss", "qu", "ch"),
"C": ("CC", "SS", "QU", "CH"),
"d": ("dd",),
"D": ("DD",),
"é": ("ai", "ei"),
"É": ("AI", "EI"),
"f": ("ff", "ph"),
"F": ("FF", "PH"),
"g": ("gu", "ge", "gg", "gh"),
"G": ("GU", "GE", "GG", "GH"),
"j": ("jj", "dj"),
"J": ("JJ", "DJ"),
"k": ("qu", "ck", "ch", "cu", "kk", "kh"),
"K": ("QU", "CK", "CH", "CU", "KK", "KH"),
"l": ("ll",),
"L": ("LL",),
"m": ("mm", "mn"),
|
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
"t": ("tt", "th"),
"T": ("TT", "TH"),
"x": ("cc", "ct", "xx"),
"X": ("CC", "CT", "XX"),
"z": ("ss", "zh"),
"Z": ("SS", "ZH"),
}
d2toX = {
"an": ("en",),
"AN": ("EN",),
"au": ("eau", "o", "ô"),
"AU": ("EAU", "O", "Ô"),
"en": ("an",),
|
>
>
>
>
>
>
>
|
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
"t": ("tt", "th"),
"T": ("TT", "TH"),
"x": ("cc", "ct", "xx"),
"X": ("CC", "CT", "XX"),
"z": ("ss", "zh"),
"Z": ("SS", "ZH"),
}
def get1toXReplacement (cPrev, cCur, cNext):
if cCur in aConsonant and (cPrev in aConsonant or cNext in aConsonant):
return ()
return d1toX.get(cCur, ())
d2toX = {
"an": ("en",),
"AN": ("EN",),
"au": ("eau", "o", "ô"),
"AU": ("EAU", "O", "Ô"),
"en": ("an",),
|