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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ascending_metrics = {
|
2 |
+
"wer",
|
3 |
+
"cer",
|
4 |
+
"loss",
|
5 |
+
"mae",
|
6 |
+
"mahalanobis",
|
7 |
+
"mse",
|
8 |
+
"perplexity",
|
9 |
+
"ter",
|
10 |
+
}
|
11 |
+
|
12 |
+
metric_ranges = {
|
13 |
+
"accuracy": (0,1),
|
14 |
+
"precision": (0,1),
|
15 |
+
"recall": (0,1),
|
16 |
+
"macro f1": (0,1),
|
17 |
+
"micro f1": (0,1),
|
18 |
+
"pearson": (-1, 1),
|
19 |
+
"matthews_correlation": (-1, 1),
|
20 |
+
"spearmanr": (-1, 1),
|
21 |
+
"google_bleu": (0, 1),
|
22 |
+
"precision@10": (0, 1),
|
23 |
+
"mae": (0, 1),
|
24 |
+
"mauve": (0, 1),
|
25 |
+
"frontier_integral": (0, 1),
|
26 |
+
"mean_iou": (0, 1),
|
27 |
+
"mean_accuracy": (0, 1),
|
28 |
+
"overall_accuracy": (0, 1),
|
29 |
+
"meteor": (0, 1),
|
30 |
+
"mse": (0, 1),
|
31 |
+
"perplexity": (0, float("inf")),
|
32 |
+
"rogue1": (0, 1),
|
33 |
+
"rogue2": (0, 1),
|
34 |
+
"sari": (0, 100),
|
35 |
+
}
|
36 |
+
|
37 |
+
CV11_LANGUAGES = {
|
38 |
+
'ab': 'Abkhaz',
|
39 |
+
'ace': 'Acehnese',
|
40 |
+
'ady': 'Adyghe',
|
41 |
+
'af': 'Afrikaans',
|
42 |
+
'am': 'Amharic',
|
43 |
+
'an': 'Aragonese',
|
44 |
+
'ar': 'Arabic',
|
45 |
+
'arn': 'Mapudungun',
|
46 |
+
'as': 'Assamese',
|
47 |
+
'ast': 'Asturian',
|
48 |
+
'az': 'Azerbaijani',
|
49 |
+
'ba': 'Bashkir',
|
50 |
+
'bas': 'Basaa',
|
51 |
+
'be': 'Belarusian',
|
52 |
+
'bg': 'Bulgarian',
|
53 |
+
'bn': 'Bengali',
|
54 |
+
'br': 'Breton',
|
55 |
+
'bs': 'Bosnian',
|
56 |
+
'bxr': 'Buryat',
|
57 |
+
'ca': 'Catalan',
|
58 |
+
'cak': 'Kaqchikel',
|
59 |
+
'ckb': 'Central Kurdish',
|
60 |
+
'cnh': 'Hakha Chin',
|
61 |
+
'co': 'Corsican',
|
62 |
+
'cs': 'Czech',
|
63 |
+
'cv': 'Chuvash',
|
64 |
+
'cy': 'Welsh',
|
65 |
+
'da': 'Danish',
|
66 |
+
'de': 'German',
|
67 |
+
'dsb': 'Sorbian, Lower',
|
68 |
+
'dv': 'Dhivehi',
|
69 |
+
'dyu': 'Dioula',
|
70 |
+
'el': 'Greek',
|
71 |
+
'en': 'English',
|
72 |
+
'eo': 'Esperanto',
|
73 |
+
'es': 'Spanish',
|
74 |
+
'et': 'Estonian',
|
75 |
+
'eu': 'Basque',
|
76 |
+
'fa': 'Persian',
|
77 |
+
'ff': 'Fulah',
|
78 |
+
'fi': 'Finnish',
|
79 |
+
'fo': 'Faroese',
|
80 |
+
'fr': 'French',
|
81 |
+
'fy-NL': 'Frisian',
|
82 |
+
'ga-IE': 'Irish',
|
83 |
+
'gl': 'Galician',
|
84 |
+
'gn': 'Guarani',
|
85 |
+
'gom': 'Goan Konkani',
|
86 |
+
'ha': 'Hausa',
|
87 |
+
'he': 'Hebrew',
|
88 |
+
'hi': 'Hindi',
|
89 |
+
'hil': 'Hiligaynon',
|
90 |
+
'hr': 'Croatian',
|
91 |
+
'hsb': 'Sorbian, Upper',
|
92 |
+
'ht': 'Haitian',
|
93 |
+
'hu': 'Hungarian',
|
94 |
+
'hy-AM': 'Armenian',
|
95 |
+
'hyw': 'Armenian Western',
|
96 |
+
'ia': 'Interlingua',
|
97 |
+
'id': 'Indonesian',
|
98 |
+
'ie': 'Interlingue',
|
99 |
+
'ig': 'Igbo',
|
100 |
+
'is': 'Icelandic',
|
101 |
+
'it': 'Italian',
|
102 |
+
'izh': 'Izhorian',
|
103 |
+
'ja': 'Japanese',
|
104 |
+
'jbo': 'Lojban',
|
105 |
+
'ka': 'Georgian',
|
106 |
+
'kaa': 'Karakalpak',
|
107 |
+
'kab': 'Kabyle',
|
108 |
+
'kbd': 'Kabardian',
|
109 |
+
'ki': 'Kikuyu',
|
110 |
+
'kk': 'Kazakh',
|
111 |
+
'km': 'Khmer',
|
112 |
+
'kmr': 'Kurmanji Kurdish',
|
113 |
+
'kn': 'Kannada',
|
114 |
+
'knn': 'Konkani (Devanagari)',
|
115 |
+
'ko': 'Korean',
|
116 |
+
'kpv': 'Komi-Zyrian',
|
117 |
+
'kw': 'Cornish',
|
118 |
+
'ky': 'Kyrgyz',
|
119 |
+
'lb': 'Luxembourgish',
|
120 |
+
'lg': 'Luganda',
|
121 |
+
'lij': 'Ligurian',
|
122 |
+
'ln': 'Lingala',
|
123 |
+
'lo': 'Lao',
|
124 |
+
'lt': 'Lithuanian',
|
125 |
+
'lv': 'Latvian',
|
126 |
+
'mai': 'Maithili',
|
127 |
+
'mdf': 'Moksha',
|
128 |
+
'mg': 'Malagasy',
|
129 |
+
'mhr': 'Meadow Mari',
|
130 |
+
'mk': 'Macedonian',
|
131 |
+
'ml': 'Malayalam',
|
132 |
+
'mn': 'Mongolian',
|
133 |
+
'mni': 'Meetei Lon',
|
134 |
+
'mos': 'Mossi',
|
135 |
+
'mr': 'Marathi',
|
136 |
+
'mrj': 'Hill Mari',
|
137 |
+
'ms': 'Malay',
|
138 |
+
'mt': 'Maltese',
|
139 |
+
'my': 'Burmese',
|
140 |
+
'myv': 'Erzya',
|
141 |
+
'nan-tw': 'Taiwanese (Minnan)',
|
142 |
+
'nb-NO': 'Norwegian Bokmål',
|
143 |
+
'nd': 'IsiNdebele (North)',
|
144 |
+
'ne-NP': 'Nepali',
|
145 |
+
'nia': 'Nias',
|
146 |
+
'nl': 'Dutch',
|
147 |
+
'nn-NO': 'Norwegian Nynorsk',
|
148 |
+
'nr': 'IsiNdebele (South)',
|
149 |
+
'nso': 'Northern Sotho',
|
150 |
+
'nyn': 'Runyankole',
|
151 |
+
'oc': 'Occitan',
|
152 |
+
'om': 'Afaan Ormoo',
|
153 |
+
'or': 'Odia',
|
154 |
+
'pa-IN': 'Punjabi',
|
155 |
+
'pap-AW': 'Papiamento (Aruba)',
|
156 |
+
'pl': 'Polish',
|
157 |
+
'ps': 'Pashto',
|
158 |
+
'pt': 'Portuguese',
|
159 |
+
'quc': "K'iche'",
|
160 |
+
'quy': 'Quechua Chanka',
|
161 |
+
'rm-sursilv': 'Romansh Sursilvan',
|
162 |
+
'rm-vallader': 'Romansh Vallader',
|
163 |
+
'ro': 'Romanian',
|
164 |
+
'ru': 'Russian',
|
165 |
+
'rw': 'Kinyarwanda',
|
166 |
+
'sah': 'Sakha',
|
167 |
+
'sat': 'Santali (Ol Chiki)',
|
168 |
+
'sc': 'Sardinian',
|
169 |
+
'scn': 'Sicilian',
|
170 |
+
'sdh': 'Southern Kurdish',
|
171 |
+
'shi': 'Shilha',
|
172 |
+
'si': 'Sinhala',
|
173 |
+
'sk': 'Slovak',
|
174 |
+
'skr': 'Saraiki',
|
175 |
+
'sl': 'Slovenian',
|
176 |
+
'snk': 'Soninke',
|
177 |
+
'so': 'Somali',
|
178 |
+
'sq': 'Albanian',
|
179 |
+
'sr': 'Serbian',
|
180 |
+
'ss': 'Siswati',
|
181 |
+
'st': 'Southern Sotho',
|
182 |
+
'sv-SE': 'Swedish',
|
183 |
+
'sw': 'Swahili',
|
184 |
+
'syr': 'Syriac',
|
185 |
+
'ta': 'Tamil',
|
186 |
+
'te': 'Telugu',
|
187 |
+
'tg': 'Tajik',
|
188 |
+
'th': 'Thai',
|
189 |
+
'ti': 'Tigrinya',
|
190 |
+
'tig': 'Tigre',
|
191 |
+
'tk': 'Turkmen',
|
192 |
+
'tl': 'Tagalog',
|
193 |
+
'tn': 'Setswana',
|
194 |
+
'tok': 'Toki Pona',
|
195 |
+
'tr': 'Turkish',
|
196 |
+
'ts': 'Xitsonga',
|
197 |
+
'tt': 'Tatar',
|
198 |
+
'tw': 'Twi',
|
199 |
+
'ty': 'Tahitian',
|
200 |
+
'uby': 'Ubykh',
|
201 |
+
'udm': 'Udmurt',
|
202 |
+
'ug': 'Uyghur',
|
203 |
+
'uk': 'Ukrainian',
|
204 |
+
'ur': 'Urdu',
|
205 |
+
'uz': 'Uzbek',
|
206 |
+
've': 'Tshivenda',
|
207 |
+
'vec': 'Venetian',
|
208 |
+
'vi': 'Vietnamese',
|
209 |
+
'vot': 'Votic',
|
210 |
+
'xh': 'Xhosa',
|
211 |
+
'yi': 'Yiddish',
|
212 |
+
'yo': 'Yoruba',
|
213 |
+
'yue': 'Cantonese',
|
214 |
+
'zgh': 'Tamazight',
|
215 |
+
'zh-CN': 'Chinese (China)',
|
216 |
+
'zh-HK': 'Chinese (Hong Kong)',
|
217 |
+
'zh-TW': 'Chinese (Taiwan)',
|
218 |
+
'zu': 'Zulu',
|
219 |
+
}
|
220 |
+
|
221 |
+
FLEURS_LANGUAGES = {
|
222 |
+
'af_za': 'Afrikaans',
|
223 |
+
'am_et': 'Amharic',
|
224 |
+
'ar_eg': 'Arabic',
|
225 |
+
'as_in': 'Assamese',
|
226 |
+
'ast_es': 'Asturian',
|
227 |
+
'az_az': 'Azerbaijani',
|
228 |
+
'be_by': 'Belarusian',
|
229 |
+
'bg_bg': 'Bulgarian',
|
230 |
+
'bn_in': 'Bengali',
|
231 |
+
'bs_ba': 'Bosnian',
|
232 |
+
'ca_es': 'Catalan',
|
233 |
+
'ceb_ph': 'Cebuano',
|
234 |
+
'ckb_iq': 'Sorani-Kurdish',
|
235 |
+
'cmn_hans_cn': 'Mandarin Chinese',
|
236 |
+
'cs_cz': 'Czech',
|
237 |
+
'cy_gb': 'Welsh',
|
238 |
+
'da_dk': 'Danish',
|
239 |
+
'de_de': 'German',
|
240 |
+
'el_gr': 'Greek',
|
241 |
+
'en_us': 'English',
|
242 |
+
'es_419': 'Spanish',
|
243 |
+
'et_ee': 'Estonian',
|
244 |
+
'fa_ir': 'Persian',
|
245 |
+
'ff_sn': 'Fula',
|
246 |
+
'fi_fi': 'Finnish',
|
247 |
+
'fil_ph': 'Filipino',
|
248 |
+
'fr_fr': 'French',
|
249 |
+
'ga_ie': 'Irish',
|
250 |
+
'gl_es': 'Galician',
|
251 |
+
'gu_in': 'Gujarati',
|
252 |
+
'ha_ng': 'Hausa',
|
253 |
+
'he_il': 'Hebrew',
|
254 |
+
'hi_in': 'Hindi',
|
255 |
+
'hr_hr': 'Croatian',
|
256 |
+
'hu_hu': 'Hungarian',
|
257 |
+
'hy_am': 'Armenian',
|
258 |
+
'id_id': 'Indonesian',
|
259 |
+
'ig_ng': 'Igbo',
|
260 |
+
'is_is': 'Icelandic',
|
261 |
+
'it_it': 'Italian',
|
262 |
+
'ja_jp': 'Japanese',
|
263 |
+
'jv_id': 'Javanese',
|
264 |
+
'ka_ge': 'Georgian',
|
265 |
+
'kam_ke': 'Kamba',
|
266 |
+
'kea_cv': 'Kabuverdianu',
|
267 |
+
'kk_kz': 'Kazakh',
|
268 |
+
'km_kh': 'Khmer',
|
269 |
+
'kn_in': 'Kannada',
|
270 |
+
'ko_kr': 'Korean',
|
271 |
+
'ky_kg': 'Kyrgyz',
|
272 |
+
'lb_lu': 'Luxembourgish',
|
273 |
+
'lg_ug': 'Ganda',
|
274 |
+
'ln_cd': 'Lingala',
|
275 |
+
'lo_la': 'Lao',
|
276 |
+
'lt_lt': 'Lithuanian',
|
277 |
+
'luo_ke': 'Luo',
|
278 |
+
'lv_lv': 'Latvian',
|
279 |
+
'mi_nz': 'Maori',
|
280 |
+
'mk_mk': 'Macedonian',
|
281 |
+
'ml_in': 'Malayalam',
|
282 |
+
'mn_mn': 'Mongolian',
|
283 |
+
'mr_in': 'Marathi',
|
284 |
+
'ms_my': 'Malay',
|
285 |
+
'mt_mt': 'Maltese',
|
286 |
+
'my_mm': 'Burmese',
|
287 |
+
'nb_no': 'Norwegian',
|
288 |
+
'ne_np': 'Nepali',
|
289 |
+
'nl_nl': 'Dutch',
|
290 |
+
'nso_za': 'Northern-Sotho',
|
291 |
+
'ny_mw': 'Nyanja',
|
292 |
+
'oc_fr': 'Occitan',
|
293 |
+
'om_et': 'Oromo',
|
294 |
+
'or_in': 'Oriya',
|
295 |
+
'pa_in': 'Punjabi',
|
296 |
+
'pl_pl': 'Polish',
|
297 |
+
'ps_af': 'Pashto',
|
298 |
+
'pt_br': 'Portuguese',
|
299 |
+
'ro_ro': 'Romanian',
|
300 |
+
'ru_ru': 'Russian',
|
301 |
+
'sd_in': 'Sindhi',
|
302 |
+
'sk_sk': 'Slovak',
|
303 |
+
'sl_si': 'Slovenian',
|
304 |
+
'sn_zw': 'Shona',
|
305 |
+
'so_so': 'Somali',
|
306 |
+
'sr_rs': 'Serbian',
|
307 |
+
'sv_se': 'Swedish',
|
308 |
+
'sw_ke': 'Swahili',
|
309 |
+
'ta_in': 'Tamil',
|
310 |
+
'te_in': 'Telugu',
|
311 |
+
'tg_tj': 'Tajik',
|
312 |
+
'th_th': 'Thai',
|
313 |
+
'tr_tr': 'Turkish',
|
314 |
+
'uk_ua': 'Ukrainian',
|
315 |
+
'umb_ao': 'Umbundu',
|
316 |
+
'ur_pk': 'Urdu',
|
317 |
+
'uz_uz': 'Uzbek',
|
318 |
+
'vi_vn': 'Vietnamese',
|
319 |
+
'wo_sn': 'Wolof',
|
320 |
+
'xh_za': 'Xhosa',
|
321 |
+
'yo_ng': 'Yoruba',
|
322 |
+
'yue_hant_hk': 'Cantonese Chinese',
|
323 |
+
'zu_za': 'Zulu',
|
324 |
+
}
|