AMRPH commited on
Commit
94962f0
·
verified ·
1 Parent(s): 1e80a53

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +39 -0
README.md CHANGED
@@ -13,3 +13,42 @@ tags:
13
  - Поддерживает несколько качественных голосов.
14
  - Уменьшенный **vocab**.
15
  - Обученная на кастомном закрытом датасете мансийского языка.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  - Поддерживает несколько качественных голосов.
14
  - Уменьшенный **vocab**.
15
  - Обученная на кастомном закрытом датасете мансийского языка.
16
+
17
+ Для предобработки текста рекомендуется использовать следующий код:
18
+ ```
19
+ lat_to_cyr = {
20
+ "a": "а", "A": "А",
21
+ "e": "е", "E": "Е",
22
+ "o": "о", "O": "О",
23
+ "y": "у", "Y": "У",
24
+ }
25
+
26
+ punct_map = {
27
+ '“': '"', '”': '"', '„': '"', '«': '"', '»': '"',
28
+ '‘': "'", '’': "'", '‚': "'",
29
+ '—': '-', '–': '-', '−': '-',
30
+ }
31
+
32
+ def normalize_text(text: str) -> str:
33
+ text = unicodedata.normalize("NFD", str(text))
34
+
35
+ for lat, cyr in lat_to_cyr.items():
36
+ text = text.replace(lat, cyr)
37
+
38
+ text = unicodedata.normalize("NFC", text)
39
+
40
+ text = ''.join(ch for ch in text if unicodedata.category(ch)[0] != 'C')
41
+
42
+ text = re.sub(r'\s+', ' ', text)
43
+
44
+ text = text.strip()
45
+
46
+ for k, v in punct_map.items():
47
+ text = text.replace(k, v)
48
+
49
+ return text
50
+
51
+ df['text'] = df['text'].apply(normalize_text)
52
+ ```
53
+
54
+