Yurii Paniv commited on
Commit
c010ef4
1 Parent(s): 8472231

Add simple English letter handling

Browse files
Files changed (1) hide show
  1. formatter.py +39 -0
formatter.py CHANGED
@@ -13,4 +13,43 @@ def preprocess_text(text):
13
  text = text.replace("8", "вісім ")
14
  text = text.replace("9", "дев'ять ")
15
  text = text.replace("0", "нуль ")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  return text
 
 
 
 
 
13
  text = text.replace("8", "вісім ")
14
  text = text.replace("9", "дев'ять ")
15
  text = text.replace("0", "нуль ")
16
+ # speak english alphabet using brute force transliteration
17
+ english = {
18
+ "a": "а",
19
+ "b": "б",
20
+ "c": "ц",
21
+ "d": "д",
22
+ "e": "е",
23
+ "f": "ф",
24
+ "g": "ґ",
25
+ "h": "г",
26
+ "i": "і",
27
+ "j": "дж",
28
+ "k": "к",
29
+ "l": "л",
30
+ "m": "м",
31
+ "n": "н",
32
+ "o": "о",
33
+ "p": "п",
34
+ "q": "кв",
35
+ "r": "р",
36
+ "s": "с",
37
+ "t": "т",
38
+ "u": "ю",
39
+ "v": "в",
40
+ "w": "в",
41
+ "x": "кс",
42
+ "y": "й",
43
+ "z": "з",
44
+ }
45
+ for english_char in english.keys():
46
+ # uppercase
47
+ text = text.replace(english_char.upper(), english[english_char].upper())
48
+ text = text.replace(english_char, english[english_char])
49
+
50
+ # TODO: autostress support here
51
  return text
52
+
53
+
54
+ if __name__ == "__main__":
55
+ print(preprocess_text("Quality of life update"))