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|
3 |
+
# console.log(Array.from(document.getElementsByClassName("text-md truncate font-mono text-black dark:group-hover/repo:text-yellow-500 group-hover/repo:text-indigo-600 text-smd")).map(element => element.innerHTML));
|
4 |
+
|
5 |
+
helsinki_models = [
|
6 |
+
"Helsinki-NLP/opus-mt-tc-base-bat-zle",
|
7 |
+
"Helsinki-NLP/opus-mt-tc-base-uk-tr",
|
8 |
+
"Helsinki-NLP/opus-mt-tc-base-hu-uk",
|
9 |
+
"Helsinki-NLP/opus-mt-tc-base-uk-ces_slk",
|
10 |
+
"Helsinki-NLP/opus-mt-tc-base-zle-bat",
|
11 |
+
"Helsinki-NLP/opus-mt-tc-base-uk-fi",
|
12 |
+
"Helsinki-NLP/opus-mt-tc-base-uk-hu",
|
13 |
+
"Helsinki-NLP/opus-mt-tc-base-tr-uk",
|
14 |
+
"Helsinki-NLP/opus-mt-tc-base-uk-ro",
|
15 |
+
"Helsinki-NLP/opus-mt-tc-base-ro-uk",
|
16 |
+
"Helsinki-NLP/opus-mt-tc-base-fi-uk",
|
17 |
+
"Helsinki-NLP/opus-tatoeba-af-ru",
|
18 |
+
"Helsinki-NLP/opus-mt-tc-base-gmw-gmw",
|
19 |
+
"Helsinki-NLP/opus-tatoeba-de-ro",
|
20 |
+
"Helsinki-NLP/opus-mt-zlw-fiu",
|
21 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-gmq",
|
22 |
+
"Helsinki-NLP/opus-mt-tc-big-gmq-he",
|
23 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-pt",
|
24 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-fi",
|
25 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-it",
|
26 |
+
"Helsinki-NLP/opus-mt-tc-big-ar-gmq",
|
27 |
+
"Helsinki-NLP/opus-mt-tc-big-fi-zle",
|
28 |
+
"Helsinki-NLP/opus-mt-tc-big-gmq-zle",
|
29 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-zls",
|
30 |
+
"Helsinki-NLP/opus-mt-tc-big-itc-eu",
|
31 |
+
"Helsinki-NLP/opus-mt-tc-big-itc-ar",
|
32 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-itc",
|
33 |
+
"Helsinki-NLP/opus-mt-tc-big-gmq-tr",
|
34 |
+
"Helsinki-NLP/opus-mt-tc-big-gmq-zlw",
|
35 |
+
"Helsinki-NLP/opus-mt-tc-big-zls-itc",
|
36 |
+
"Helsinki-NLP/opus-mt-tc-big-gmq-ar",
|
37 |
+
"Helsinki-NLP/opus-mt-tc-big-zls-zle",
|
38 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-es",
|
39 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-fr",
|
40 |
+
"Helsinki-NLP/opus-mt-tc-big-he-itc",
|
41 |
+
"Helsinki-NLP/opus-mt-tc-big-he-gmq",
|
42 |
+
"Helsinki-NLP/opus-mt-tc-big-itc-he",
|
43 |
+
"Helsinki-NLP/opus-mt-tc-big-cel-en",
|
44 |
+
"Helsinki-NLP/opus-mt-tc-big-de-gmq",
|
45 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-zle",
|
46 |
+
"Helsinki-NLP/opus-mt-tc-big-es-zle",
|
47 |
+
"Helsinki-NLP/opus-mt-tc-big-gmq-itc",
|
48 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-zlw",
|
49 |
+
"Helsinki-NLP/opus-mt-tc-big-it-zle",
|
50 |
+
"Helsinki-NLP/opus-mt-tc-big-fr-zle",
|
51 |
+
"Helsinki-NLP/opus-mt-tc-big-pt-zle",
|
52 |
+
"Helsinki-NLP/opus-mt-tc-big-zlw-zle",
|
53 |
+
"Helsinki-NLP/opus-mt-tc-big-fi-zls",
|
54 |
+
"Helsinki-NLP/opus-mt-tc-big-de-zle",
|
55 |
+
"Helsinki-NLP/opus-mt-tc-big-gmq-gmq",
|
56 |
+
"Helsinki-NLP/opus-mt-tc-big-itc-tr",
|
57 |
+
"Helsinki-NLP/opus-mt-tc-big-de-es",
|
58 |
+
"Helsinki-NLP/opus-mt-tc-big-zlw-en",
|
59 |
+
"Helsinki-NLP/opus-mt-tc-big-fa-itc",
|
60 |
+
"Helsinki-NLP/opus-mt-tc-big-ar-itc",
|
61 |
+
"Helsinki-NLP/opus-mt-tc-big-eu-itc",
|
62 |
+
"Helsinki-NLP/opus-mt-tc-big-fa-gmq",
|
63 |
+
"Helsinki-NLP/opus-mt-tc-big-zls-de",
|
64 |
+
"Helsinki-NLP/opus-mt-tc-big-itc-itc",
|
65 |
+
"Helsinki-NLP/opus-mt-tc-big-lv-en",
|
66 |
+
"Helsinki-NLP/opus-mt-tc-big-gmq-en",
|
67 |
+
"Helsinki-NLP/opus-mt-tc-big-bg-en",
|
68 |
+
"Helsinki-NLP/opus-mt-tc-big-hu-en",
|
69 |
+
"Helsinki-NLP/opus-mt-tc-big-zh-ja",
|
70 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-de",
|
71 |
+
"Helsinki-NLP/opus-mt-tc-big-lt-en",
|
72 |
+
"Helsinki-NLP/opus-mt-tc-big-ko-en",
|
73 |
+
"Helsinki-NLP/opus-mt-tc-big-et-en",
|
74 |
+
"Helsinki-NLP/opus-mt-tc-big-en-it",
|
75 |
+
"Helsinki-NLP/opus-mt-tc-big-sh-en",
|
76 |
+
"Helsinki-NLP/opus-mt-tc-big-zls-en",
|
77 |
+
"Helsinki-NLP/opus-mt-tc-big-zle-en",
|
78 |
+
"Helsinki-NLP/opus-mt-tc-big-en-es",
|
79 |
+
"Helsinki-NLP/opus-mt-tc-big-fr-en",
|
80 |
+
"Helsinki-NLP/opus-mt-tc-big-he-en",
|
81 |
+
"Helsinki-NLP/opus-mt-tc-big-en-fr",
|
82 |
+
"Helsinki-NLP/opus-mt-tc-big-gmw-gmw",
|
83 |
+
"Helsinki-NLP/opus-mt-tc-big-itc-bat",
|
84 |
+
"Helsinki-NLP/opus-mt-tc-big-tr-en",
|
85 |
+
"Helsinki-NLP/opus-mt-tc-big-it-en",
|
86 |
+
"Helsinki-NLP/opus-mt-tc-big-el-en",
|
87 |
+
"Helsinki-NLP/opus-mt-tc-big-ces_slk-en",
|
88 |
+
"Helsinki-NLP/opus-mt-tc-big-cat_oci_spa-en",
|
89 |
+
"Helsinki-NLP/opus-mt-tc-big-ar-en",
|
90 |
+
"Helsinki-NLP/opus-mt-tc-base-ces_slk-uk",
|
91 |
+
"Helsinki-NLP/opus-mt-tc-big-fi-en",
|
92 |
+
"Helsinki-NLP/opus-tatoeba-it-he",
|
93 |
+
"Helsinki-NLP/opus-tatoeba-he-it",
|
94 |
+
"Helsinki-NLP/opus-tatoeba-he-fr",
|
95 |
+
"Helsinki-NLP/opus-tatoeba-fr-it",
|
96 |
+
"Helsinki-NLP/opus-tatoeba-es-zh",
|
97 |
+
"Helsinki-NLP/opus-mt-it-vi",
|
98 |
+
"Helsinki-NLP/opus-mt-it-uk",
|
99 |
+
"Helsinki-NLP/opus-mt-it-sv",
|
100 |
+
"Helsinki-NLP/opus-mt-it-ms",
|
101 |
+
"Helsinki-NLP/opus-mt-it-lt",
|
102 |
+
"Helsinki-NLP/opus-mt-it-is",
|
103 |
+
"Helsinki-NLP/opus-mt-it-fr",
|
104 |
+
"Helsinki-NLP/opus-mt-it-es",
|
105 |
+
"Helsinki-NLP/opus-mt-it-eo",
|
106 |
+
"Helsinki-NLP/opus-mt-it-en",
|
107 |
+
"Helsinki-NLP/opus-mt-it-de",
|
108 |
+
"Helsinki-NLP/opus-mt-it-ca",
|
109 |
+
"Helsinki-NLP/opus-mt-it-bg",
|
110 |
+
"Helsinki-NLP/opus-mt-it-ar",
|
111 |
+
"Helsinki-NLP/opus-mt-fr-zne",
|
112 |
+
"Helsinki-NLP/opus-mt-fr-yo",
|
113 |
+
"Helsinki-NLP/opus-mt-fr-yap",
|
114 |
+
"Helsinki-NLP/opus-mt-fr-xh",
|
115 |
+
"Helsinki-NLP/opus-mt-fr-wls",
|
116 |
+
"Helsinki-NLP/opus-mt-fr-war",
|
117 |
+
"Helsinki-NLP/opus-mt-fr-vi",
|
118 |
+
"Helsinki-NLP/opus-mt-fr-ve",
|
119 |
+
"Helsinki-NLP/opus-mt-fr-uk",
|
120 |
+
"Helsinki-NLP/opus-mt-fr-ty",
|
121 |
+
"Helsinki-NLP/opus-mt-fr-tw",
|
122 |
+
"Helsinki-NLP/opus-mt-fr-tvl",
|
123 |
+
"Helsinki-NLP/opus-mt-fr-tum",
|
124 |
+
"Helsinki-NLP/opus-mt-fr-ts",
|
125 |
+
"Helsinki-NLP/opus-mt-fr-tpi",
|
126 |
+
"Helsinki-NLP/opus-mt-fr-to",
|
127 |
+
"Helsinki-NLP/opus-mt-fr-tn",
|
128 |
+
"Helsinki-NLP/opus-mt-fr-tll",
|
129 |
+
"Helsinki-NLP/opus-mt-fr-tl",
|
130 |
+
"Helsinki-NLP/opus-mt-fr-tiv",
|
131 |
+
"Helsinki-NLP/opus-mt-fr-swc",
|
132 |
+
"Helsinki-NLP/opus-mt-fr-sv",
|
133 |
+
"Helsinki-NLP/opus-mt-fr-st",
|
134 |
+
"Helsinki-NLP/opus-mt-fr-srn",
|
135 |
+
"Helsinki-NLP/opus-mt-fr-sn",
|
136 |
+
"Helsinki-NLP/opus-mt-fr-sm",
|
137 |
+
"Helsinki-NLP/opus-mt-fr-sl",
|
138 |
+
"Helsinki-NLP/opus-mt-fr-sk",
|
139 |
+
"Helsinki-NLP/opus-mt-fr-sg",
|
140 |
+
"Helsinki-NLP/opus-mt-fr-rw",
|
141 |
+
"Helsinki-NLP/opus-mt-fr-run",
|
142 |
+
"Helsinki-NLP/opus-mt-fr-ru",
|
143 |
+
"Helsinki-NLP/opus-mt-fr-ro",
|
144 |
+
"Helsinki-NLP/opus-mt-fr-rnd",
|
145 |
+
"Helsinki-NLP/opus-mt-fr-pon",
|
146 |
+
"Helsinki-NLP/opus-mt-fr-pl",
|
147 |
+
"Helsinki-NLP/opus-mt-fr-pis",
|
148 |
+
"Helsinki-NLP/opus-mt-fr-pap",
|
149 |
+
"Helsinki-NLP/opus-mt-fr-pag",
|
150 |
+
"Helsinki-NLP/opus-mt-fr-ny",
|
151 |
+
"Helsinki-NLP/opus-mt-fr-nso",
|
152 |
+
"Helsinki-NLP/opus-mt-fr-no",
|
153 |
+
"Helsinki-NLP/opus-mt-fr-niu",
|
154 |
+
"Helsinki-NLP/opus-mt-fr-mt",
|
155 |
+
"Helsinki-NLP/opus-mt-fr-ms",
|
156 |
+
"Helsinki-NLP/opus-mt-fr-mos",
|
157 |
+
"Helsinki-NLP/opus-mt-fr-mh",
|
158 |
+
"Helsinki-NLP/opus-mt-fr-mfe",
|
159 |
+
"Helsinki-NLP/opus-mt-fr-lus",
|
160 |
+
"Helsinki-NLP/opus-mt-fr-lue",
|
161 |
+
"Helsinki-NLP/opus-mt-fr-lua",
|
162 |
+
"Helsinki-NLP/opus-mt-fr-lu",
|
163 |
+
"Helsinki-NLP/opus-mt-fr-loz",
|
164 |
+
"Helsinki-NLP/opus-mt-fr-ln",
|
165 |
+
"Helsinki-NLP/opus-mt-fr-lg",
|
166 |
+
"Helsinki-NLP/opus-mt-fr-kwy",
|
167 |
+
"Helsinki-NLP/opus-mt-fr-kqn",
|
168 |
+
"Helsinki-NLP/opus-mt-fr-kg",
|
169 |
+
"Helsinki-NLP/opus-mt-fr-iso",
|
170 |
+
"Helsinki-NLP/opus-mt-fr-ilo",
|
171 |
+
"Helsinki-NLP/opus-mt-fr-ig",
|
172 |
+
"Helsinki-NLP/opus-mt-fr-id",
|
173 |
+
"Helsinki-NLP/opus-mt-fr-hu",
|
174 |
+
"Helsinki-NLP/opus-mt-fr-ht",
|
175 |
+
"Helsinki-NLP/opus-mt-fr-hr",
|
176 |
+
"Helsinki-NLP/opus-mt-fr-ho",
|
177 |
+
"Helsinki-NLP/opus-mt-fr-hil",
|
178 |
+
"Helsinki-NLP/opus-mt-fr-he",
|
179 |
+
"Helsinki-NLP/opus-mt-fr-ha",
|
180 |
+
"Helsinki-NLP/opus-mt-fr-guw",
|
181 |
+
"Helsinki-NLP/opus-mt-fr-gil",
|
182 |
+
"Helsinki-NLP/opus-mt-fr-gaa",
|
183 |
+
"Helsinki-NLP/opus-mt-fr-fj",
|
184 |
+
"Helsinki-NLP/opus-mt-fr-es",
|
185 |
+
"Helsinki-NLP/opus-mt-fr-eo",
|
186 |
+
"Helsinki-NLP/opus-mt-fr-en",
|
187 |
+
"Helsinki-NLP/opus-mt-fr-el",
|
188 |
+
"Helsinki-NLP/opus-mt-fr-efi",
|
189 |
+
"Helsinki-NLP/opus-mt-fr-ee",
|
190 |
+
"Helsinki-NLP/opus-mt-fr-de",
|
191 |
+
"Helsinki-NLP/opus-mt-fr-crs",
|
192 |
+
"Helsinki-NLP/opus-mt-fr-ceb",
|
193 |
+
"Helsinki-NLP/opus-mt-fr-ca",
|
194 |
+
"Helsinki-NLP/opus-mt-fr-bzs",
|
195 |
+
"Helsinki-NLP/opus-mt-fr-bi",
|
196 |
+
"Helsinki-NLP/opus-mt-fr-bg",
|
197 |
+
"Helsinki-NLP/opus-mt-fr-ber",
|
198 |
+
"Helsinki-NLP/opus-mt-fr-bem",
|
199 |
+
"Helsinki-NLP/opus-mt-fr-bcl",
|
200 |
+
"Helsinki-NLP/opus-mt-fr-ase",
|
201 |
+
"Helsinki-NLP/opus-mt-fr-ar",
|
202 |
+
"Helsinki-NLP/opus-mt-fr-af",
|
203 |
+
"Helsinki-NLP/opus-mt-eu-ru",
|
204 |
+
"Helsinki-NLP/opus-mt-eu-es",
|
205 |
+
"Helsinki-NLP/opus-mt-eu-en",
|
206 |
+
"Helsinki-NLP/opus-mt-eu-de",
|
207 |
+
"Helsinki-NLP/opus-mt-et-sv",
|
208 |
+
"Helsinki-NLP/opus-mt-et-ru",
|
209 |
+
"Helsinki-NLP/opus-mt-et-fr",
|
210 |
+
"Helsinki-NLP/opus-mt-et-fi",
|
211 |
+
"Helsinki-NLP/opus-mt-et-es",
|
212 |
+
"Helsinki-NLP/opus-mt-et-en",
|
213 |
+
"Helsinki-NLP/opus-mt-et-de",
|
214 |
+
"Helsinki-NLP/opus-mt-es-zai",
|
215 |
+
"Helsinki-NLP/opus-mt-es-yua",
|
216 |
+
"Helsinki-NLP/opus-mt-es-yo",
|
217 |
+
"Helsinki-NLP/opus-mt-es-xh",
|
218 |
+
"Helsinki-NLP/opus-mt-es-wls",
|
219 |
+
"Helsinki-NLP/opus-mt-es-war",
|
220 |
+
"Helsinki-NLP/opus-mt-es-vi",
|
221 |
+
"Helsinki-NLP/opus-mt-es-ve",
|
222 |
+
"Helsinki-NLP/opus-mt-es-uk",
|
223 |
+
"Helsinki-NLP/opus-mt-es-tzo",
|
224 |
+
"Helsinki-NLP/opus-mt-es-ty",
|
225 |
+
"Helsinki-NLP/opus-mt-es-tw",
|
226 |
+
"Helsinki-NLP/opus-mt-es-tvl",
|
227 |
+
"Helsinki-NLP/opus-mt-es-tpi",
|
228 |
+
"Helsinki-NLP/opus-mt-es-to",
|
229 |
+
"Helsinki-NLP/opus-mt-es-tn",
|
230 |
+
"Helsinki-NLP/opus-mt-es-tll",
|
231 |
+
"Helsinki-NLP/opus-mt-es-tl",
|
232 |
+
"Helsinki-NLP/opus-mt-es-swc",
|
233 |
+
"Helsinki-NLP/opus-mt-es-st",
|
234 |
+
"Helsinki-NLP/opus-mt-es-srn",
|
235 |
+
"Helsinki-NLP/opus-mt-es-sn",
|
236 |
+
"Helsinki-NLP/opus-mt-es-sm",
|
237 |
+
"Helsinki-NLP/opus-mt-es-sl",
|
238 |
+
"Helsinki-NLP/opus-mt-es-sg",
|
239 |
+
"Helsinki-NLP/opus-mt-es-rw",
|
240 |
+
"Helsinki-NLP/opus-mt-es-ru",
|
241 |
+
"Helsinki-NLP/opus-mt-es-ro",
|
242 |
+
"Helsinki-NLP/opus-mt-es-rn",
|
243 |
+
"Helsinki-NLP/opus-mt-es-prl",
|
244 |
+
"Helsinki-NLP/opus-mt-es-pon",
|
245 |
+
"Helsinki-NLP/opus-mt-es-pl",
|
246 |
+
"Helsinki-NLP/opus-mt-es-pis",
|
247 |
+
"Helsinki-NLP/opus-mt-es-pap",
|
248 |
+
"Helsinki-NLP/opus-mt-es-pag",
|
249 |
+
"Helsinki-NLP/opus-mt-es-ny",
|
250 |
+
"Helsinki-NLP/opus-mt-es-nso",
|
251 |
+
"Helsinki-NLP/opus-mt-es-no",
|
252 |
+
"Helsinki-NLP/opus-mt-es-nl",
|
253 |
+
"Helsinki-NLP/opus-mt-es-niu",
|
254 |
+
"Helsinki-NLP/opus-mt-es-mt",
|
255 |
+
"Helsinki-NLP/opus-mt-es-mk",
|
256 |
+
"Helsinki-NLP/opus-mt-es-mfs",
|
257 |
+
"Helsinki-NLP/opus-mt-es-lus",
|
258 |
+
"Helsinki-NLP/opus-mt-es-lua",
|
259 |
+
"Helsinki-NLP/opus-mt-es-lt",
|
260 |
+
"Helsinki-NLP/opus-mt-es-loz",
|
261 |
+
"Helsinki-NLP/opus-mt-es-ln",
|
262 |
+
"Helsinki-NLP/opus-mt-es-kg",
|
263 |
+
"Helsinki-NLP/opus-mt-es-it",
|
264 |
+
"Helsinki-NLP/opus-mt-es-iso",
|
265 |
+
"Helsinki-NLP/opus-mt-es-is",
|
266 |
+
"Helsinki-NLP/opus-mt-es-ilo",
|
267 |
+
"Helsinki-NLP/opus-mt-es-ig",
|
268 |
+
"Helsinki-NLP/opus-mt-es-id",
|
269 |
+
"Helsinki-NLP/opus-mt-es-ht",
|
270 |
+
"Helsinki-NLP/opus-mt-es-hr",
|
271 |
+
"Helsinki-NLP/opus-mt-es-ho",
|
272 |
+
"Helsinki-NLP/opus-mt-es-hil",
|
273 |
+
"Helsinki-NLP/opus-mt-es-he",
|
274 |
+
"Helsinki-NLP/opus-mt-es-ha",
|
275 |
+
"Helsinki-NLP/opus-mt-es-guw",
|
276 |
+
"Helsinki-NLP/opus-mt-es-gl",
|
277 |
+
"Helsinki-NLP/opus-mt-es-gil",
|
278 |
+
"Helsinki-NLP/opus-mt-es-gaa",
|
279 |
+
"Helsinki-NLP/opus-mt-es-fr",
|
280 |
+
"Helsinki-NLP/opus-mt-es-fj",
|
281 |
+
"Helsinki-NLP/opus-mt-es-fi",
|
282 |
+
"Helsinki-NLP/opus-mt-es-eu",
|
283 |
+
"Helsinki-NLP/opus-mt-es-et",
|
284 |
+
"Helsinki-NLP/opus-mt-es-es",
|
285 |
+
"Helsinki-NLP/opus-mt-es-eo",
|
286 |
+
"Helsinki-NLP/opus-mt-es-en",
|
287 |
+
"Helsinki-NLP/opus-mt-es-el",
|
288 |
+
"Helsinki-NLP/opus-mt-es-efi",
|
289 |
+
"Helsinki-NLP/opus-mt-es-ee",
|
290 |
+
"Helsinki-NLP/opus-mt-es-de",
|
291 |
+
"Helsinki-NLP/opus-mt-es-da",
|
292 |
+
"Helsinki-NLP/opus-mt-es-csn",
|
293 |
+
"Helsinki-NLP/opus-mt-es-csg",
|
294 |
+
"Helsinki-NLP/opus-mt-es-cs",
|
295 |
+
"Helsinki-NLP/opus-mt-es-crs",
|
296 |
+
"Helsinki-NLP/opus-mt-es-ceb",
|
297 |
+
"Helsinki-NLP/opus-mt-es-ca",
|
298 |
+
"Helsinki-NLP/opus-mt-es-bzs",
|
299 |
+
"Helsinki-NLP/opus-mt-es-bi",
|
300 |
+
"Helsinki-NLP/opus-mt-es-bg",
|
301 |
+
"Helsinki-NLP/opus-mt-es-ber",
|
302 |
+
"Helsinki-NLP/opus-mt-es-bcl",
|
303 |
+
"Helsinki-NLP/opus-mt-es-ase",
|
304 |
+
"Helsinki-NLP/opus-mt-es-ar",
|
305 |
+
"Helsinki-NLP/opus-mt-es-af",
|
306 |
+
"Helsinki-NLP/opus-mt-es-aed",
|
307 |
+
"Helsinki-NLP/opus-mt-es-NORWAY",
|
308 |
+
"Helsinki-NLP/opus-mt-en_el_es_fi-en_el_es_fi",
|
309 |
+
"Helsinki-NLP/opus-mt-en-zlw",
|
310 |
+
"Helsinki-NLP/opus-mt-en-zls",
|
311 |
+
"Helsinki-NLP/opus-mt-en-zle",
|
312 |
+
"Helsinki-NLP/opus-mt-en-zh",
|
313 |
+
"Helsinki-NLP/opus-mt-en-xh",
|
314 |
+
"Helsinki-NLP/opus-mt-en-vi",
|
315 |
+
"Helsinki-NLP/opus-mt-en-urj",
|
316 |
+
"Helsinki-NLP/opus-mt-en-ur",
|
317 |
+
"Helsinki-NLP/opus-mt-en-umb",
|
318 |
+
"Helsinki-NLP/opus-mt-en-uk",
|
319 |
+
"Helsinki-NLP/opus-mt-en-ty",
|
320 |
+
"Helsinki-NLP/opus-mt-en-tw",
|
321 |
+
"Helsinki-NLP/opus-mt-en-tvl",
|
322 |
+
"Helsinki-NLP/opus-mt-en-tut",
|
323 |
+
"Helsinki-NLP/opus-mt-en-ts",
|
324 |
+
"Helsinki-NLP/opus-mt-en-trk",
|
325 |
+
"Helsinki-NLP/opus-mt-en-tpi",
|
326 |
+
"Helsinki-NLP/opus-mt-en-toi",
|
327 |
+
"Helsinki-NLP/opus-mt-en-to",
|
328 |
+
"Helsinki-NLP/opus-mt-en-tn",
|
329 |
+
"Helsinki-NLP/opus-mt-en-tll",
|
330 |
+
"Helsinki-NLP/opus-mt-en-tl",
|
331 |
+
"Helsinki-NLP/opus-mt-en-tiv",
|
332 |
+
"Helsinki-NLP/opus-mt-en-ti",
|
333 |
+
"Helsinki-NLP/opus-mt-en-tdt",
|
334 |
+
"Helsinki-NLP/opus-mt-en-swc",
|
335 |
+
"Helsinki-NLP/opus-mt-en-sw",
|
336 |
+
"Helsinki-NLP/opus-mt-en-sv",
|
337 |
+
"Helsinki-NLP/opus-mt-en-st",
|
338 |
+
"Helsinki-NLP/opus-mt-en-ss",
|
339 |
+
"Helsinki-NLP/opus-mt-en-sq",
|
340 |
+
"Helsinki-NLP/opus-mt-en-sn",
|
341 |
+
"Helsinki-NLP/opus-mt-en-sm",
|
342 |
+
"Helsinki-NLP/opus-mt-en-sla",
|
343 |
+
"Helsinki-NLP/opus-mt-en-sk",
|
344 |
+
"Helsinki-NLP/opus-mt-en-sit",
|
345 |
+
"Helsinki-NLP/opus-mt-en-sg",
|
346 |
+
"Helsinki-NLP/opus-mt-en-sem",
|
347 |
+
"Helsinki-NLP/opus-mt-en-sal",
|
348 |
+
"Helsinki-NLP/opus-mt-en-rw",
|
349 |
+
"Helsinki-NLP/opus-mt-en-run",
|
350 |
+
"Helsinki-NLP/opus-mt-en-ru",
|
351 |
+
"Helsinki-NLP/opus-mt-en-roa",
|
352 |
+
"Helsinki-NLP/opus-mt-en-ro",
|
353 |
+
"Helsinki-NLP/opus-mt-en-rnd",
|
354 |
+
"Helsinki-NLP/opus-mt-en-rn",
|
355 |
+
"Helsinki-NLP/opus-mt-en-pqw",
|
356 |
+
"Helsinki-NLP/opus-mt-en-pqe",
|
357 |
+
"Helsinki-NLP/opus-mt-en-poz",
|
358 |
+
"Helsinki-NLP/opus-mt-en-pon",
|
359 |
+
"Helsinki-NLP/opus-mt-en-pis",
|
360 |
+
"Helsinki-NLP/opus-mt-en-phi",
|
361 |
+
"Helsinki-NLP/opus-mt-en-pap",
|
362 |
+
"Helsinki-NLP/opus-mt-en-pag",
|
363 |
+
"Helsinki-NLP/opus-mt-en-om",
|
364 |
+
"Helsinki-NLP/opus-mt-en-nyk",
|
365 |
+
"Helsinki-NLP/opus-mt-en-ny",
|
366 |
+
"Helsinki-NLP/opus-mt-en-nso",
|
367 |
+
"Helsinki-NLP/opus-mt-en-nl",
|
368 |
+
"Helsinki-NLP/opus-mt-en-niu",
|
369 |
+
"Helsinki-NLP/opus-mt-en-nic",
|
370 |
+
"Helsinki-NLP/opus-mt-en-ng",
|
371 |
+
"Helsinki-NLP/opus-mt-en-mul",
|
372 |
+
"Helsinki-NLP/opus-mt-en-mt",
|
373 |
+
"Helsinki-NLP/opus-mt-en-mr",
|
374 |
+
"Helsinki-NLP/opus-mt-en-mos",
|
375 |
+
"Helsinki-NLP/opus-mt-en-ml",
|
376 |
+
"Helsinki-NLP/opus-mt-en-mkh",
|
377 |
+
"Helsinki-NLP/opus-mt-en-mk",
|
378 |
+
"Helsinki-NLP/opus-mt-en-mh",
|
379 |
+
"Helsinki-NLP/opus-mt-en-mg",
|
380 |
+
"Helsinki-NLP/opus-mt-en-mfe",
|
381 |
+
"Helsinki-NLP/opus-mt-en-map",
|
382 |
+
"Helsinki-NLP/opus-mt-en-lus",
|
383 |
+
"Helsinki-NLP/opus-mt-en-luo",
|
384 |
+
"Helsinki-NLP/opus-mt-en-lun",
|
385 |
+
"Helsinki-NLP/opus-mt-en-lue",
|
386 |
+
"Helsinki-NLP/opus-mt-en-lua",
|
387 |
+
"Helsinki-NLP/opus-mt-en-lu",
|
388 |
+
"Helsinki-NLP/opus-mt-en-loz",
|
389 |
+
"Helsinki-NLP/opus-mt-en-ln",
|
390 |
+
"Helsinki-NLP/opus-mt-en-lg",
|
391 |
+
"Helsinki-NLP/opus-mt-en-kwy",
|
392 |
+
"Helsinki-NLP/opus-mt-en-kwn",
|
393 |
+
"Helsinki-NLP/opus-mt-en-kqn",
|
394 |
+
"Helsinki-NLP/opus-mt-en-kj",
|
395 |
+
"Helsinki-NLP/opus-mt-en-kg",
|
396 |
+
"Helsinki-NLP/opus-mt-en-jap",
|
397 |
+
"Helsinki-NLP/opus-mt-en-itc",
|
398 |
+
"Helsinki-NLP/opus-mt-en-it",
|
399 |
+
"Helsinki-NLP/opus-mt-en-iso",
|
400 |
+
"Helsinki-NLP/opus-mt-en-is",
|
401 |
+
"Helsinki-NLP/opus-mt-en-ine",
|
402 |
+
"Helsinki-NLP/opus-mt-en-inc",
|
403 |
+
"Helsinki-NLP/opus-mt-en-ilo",
|
404 |
+
"Helsinki-NLP/opus-mt-en-iir",
|
405 |
+
"Helsinki-NLP/opus-mt-en-ig",
|
406 |
+
"Helsinki-NLP/opus-mt-en-id",
|
407 |
+
"Helsinki-NLP/opus-mt-en-hy",
|
408 |
+
"Helsinki-NLP/opus-mt-en-hu",
|
409 |
+
"Helsinki-NLP/opus-mt-en-ht",
|
410 |
+
"Helsinki-NLP/opus-mt-en-ho",
|
411 |
+
"Helsinki-NLP/opus-mt-en-hil",
|
412 |
+
"Helsinki-NLP/opus-mt-en-hi",
|
413 |
+
"Helsinki-NLP/opus-mt-en-he",
|
414 |
+
"Helsinki-NLP/opus-mt-en-ha",
|
415 |
+
"Helsinki-NLP/opus-mt-en-gv",
|
416 |
+
"Helsinki-NLP/opus-mt-en-guw",
|
417 |
+
"Helsinki-NLP/opus-mt-en-grk",
|
418 |
+
"Helsinki-NLP/opus-mt-en-gmw",
|
419 |
+
"Helsinki-NLP/opus-mt-en-gmq",
|
420 |
+
"Helsinki-NLP/opus-mt-en-gl",
|
421 |
+
"Helsinki-NLP/opus-mt-en-gil",
|
422 |
+
"Helsinki-NLP/opus-mt-en-gem",
|
423 |
+
"Helsinki-NLP/opus-mt-en-gaa",
|
424 |
+
"Helsinki-NLP/opus-mt-en-ga",
|
425 |
+
"Helsinki-NLP/opus-mt-en-fr",
|
426 |
+
"Helsinki-NLP/opus-mt-en-fj",
|
427 |
+
"Helsinki-NLP/opus-mt-en-fiu",
|
428 |
+
"Helsinki-NLP/opus-mt-en-fi",
|
429 |
+
"Helsinki-NLP/opus-mt-en-euq",
|
430 |
+
"Helsinki-NLP/opus-mt-en-eu",
|
431 |
+
"Helsinki-NLP/opus-mt-en-et",
|
432 |
+
"Helsinki-NLP/opus-mt-en-es",
|
433 |
+
"Helsinki-NLP/opus-mt-en-eo",
|
434 |
+
"Helsinki-NLP/opus-mt-en-el",
|
435 |
+
"Helsinki-NLP/opus-mt-en-efi",
|
436 |
+
"Helsinki-NLP/opus-mt-en-ee",
|
437 |
+
"Helsinki-NLP/opus-mt-en-dra",
|
438 |
+
"Helsinki-NLP/opus-mt-en-de",
|
439 |
+
"Helsinki-NLP/opus-mt-en-da",
|
440 |
+
"Helsinki-NLP/opus-mt-en-cy",
|
441 |
+
"Helsinki-NLP/opus-mt-en-cus",
|
442 |
+
"Helsinki-NLP/opus-mt-en-cs",
|
443 |
+
"Helsinki-NLP/opus-mt-en-crs",
|
444 |
+
"Helsinki-NLP/opus-mt-en-cpp",
|
445 |
+
"Helsinki-NLP/opus-mt-en-cpf",
|
446 |
+
"Helsinki-NLP/opus-mt-en-chk",
|
447 |
+
"Helsinki-NLP/opus-mt-en-cel",
|
448 |
+
"Helsinki-NLP/opus-mt-en-ceb",
|
449 |
+
"Helsinki-NLP/opus-mt-en-ca",
|
450 |
+
"Helsinki-NLP/opus-mt-en-bzs",
|
451 |
+
"Helsinki-NLP/opus-mt-en-bnt",
|
452 |
+
"Helsinki-NLP/opus-mt-en-bi",
|
453 |
+
"Helsinki-NLP/opus-mt-en-bg",
|
454 |
+
"Helsinki-NLP/opus-mt-en-ber",
|
455 |
+
"Helsinki-NLP/opus-mt-en-bem",
|
456 |
+
"Helsinki-NLP/opus-mt-en-bcl",
|
457 |
+
"Helsinki-NLP/opus-mt-en-bat",
|
458 |
+
"Helsinki-NLP/opus-mt-en-az",
|
459 |
+
"Helsinki-NLP/opus-mt-en-ar",
|
460 |
+
"Helsinki-NLP/opus-mt-en-alv",
|
461 |
+
"Helsinki-NLP/opus-mt-en-afa",
|
462 |
+
"Helsinki-NLP/opus-mt-en-af",
|
463 |
+
"Helsinki-NLP/opus-mt-en-aav",
|
464 |
+
"Helsinki-NLP/opus-mt-en-ROMANCE",
|
465 |
+
"Helsinki-NLP/opus-mt-en-CELTIC",
|
466 |
+
]
|
467 |
+
|
468 |
+
def get_clearly_formatted_langauge_directions():
|
469 |
+
# Clearly formatted language directions only
|
470 |
+
# Helsinki-NLP/opus-mt-tc-base-bat-zle is ignored
|
471 |
+
# Helsinki-NLP/opus-mt-tc-fr-en is accepted due to clarity of source language being fr and target language being en
|
472 |
+
language_directions = [model.split("Helsinki-NLP/opus-mt-")[1] for model in helsinki_models
|
473 |
+
if (len(model.split("-"))<6 and
|
474 |
+
"opus-mt" in model and
|
475 |
+
len(model.split("_")) == 1)
|
476 |
+
and len(model) < len("Helsinki-NLP/opus-mt-src-trg")]
|
477 |
+
return language_directions
|
traductor.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from collections import OrderedDict
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
def get_all_source_languages():
|
6 |
+
"""
|
7 |
+
Returns a human-readable `dict source_languages_names:codes`
|
8 |
+
based on the available models.
|
9 |
+
"""
|
10 |
+
source_languages = {
|
11 |
+
"English": "en",
|
12 |
+
"French": "fr",
|
13 |
+
"Spanish": "es",
|
14 |
+
"German": "de",
|
15 |
+
"Italian": "it"
|
16 |
+
}
|
17 |
+
source_languages = OrderedDict(sorted(source_languages.items()))
|
18 |
+
return source_languages
|
19 |
+
|
20 |
+
source_lang_dict = get_all_source_languages()
|
21 |
+
target_lang_dict = source_lang_dict # Reutilizamos el mismo diccionario para los idiomas de destino
|
22 |
+
|
23 |
+
def translate(input_text, source, target):
|
24 |
+
# Convertir nombres legibles a c贸digos abreviados
|
25 |
+
source_code = source_lang_dict.get(source, source) # 'en', 'fr', etc.
|
26 |
+
target_code = target_lang_dict.get(target, target) # 'en', 'fr', etc.
|
27 |
+
|
28 |
+
try:
|
29 |
+
model_name = f"Helsinki-NLP/opus-mt-{source_code}-{target_code}"
|
30 |
+
pipe = pipeline("translation", model=model_name)
|
31 |
+
translation = pipe(input_text)
|
32 |
+
return translation[0]['translation_text'], ""
|
33 |
+
except Exception as e:
|
34 |
+
return "", f"Error: {str(e)}"
|
35 |
+
|
36 |
+
with gr.Blocks() as demo:
|
37 |
+
gr.HTML("""
|
38 |
+
<html>
|
39 |
+
<head><style>h1 { text-align: center; }</style></head>
|
40 |
+
<body><h1>Open Translate</h1></body>
|
41 |
+
</html>
|
42 |
+
""")
|
43 |
+
with gr.Row():
|
44 |
+
with gr.Column():
|
45 |
+
source_language_dropdown = gr.Dropdown(
|
46 |
+
choices=list(source_lang_dict.keys()),
|
47 |
+
value=list(source_lang_dict.keys())[0],
|
48 |
+
label="Source Language"
|
49 |
+
)
|
50 |
+
input_textbox = gr.Textbox(
|
51 |
+
lines=5, placeholder="Enter text to translate", label="Input Text"
|
52 |
+
)
|
53 |
+
with gr.Column():
|
54 |
+
target_language_dropdown = gr.Dropdown(
|
55 |
+
choices=list(target_lang_dict.keys()),
|
56 |
+
value="English",
|
57 |
+
label="Target Language"
|
58 |
+
)
|
59 |
+
translated_textbox = gr.Textbox(lines=5, placeholder="", label="Translated Text")
|
60 |
+
info_label = gr.HTML("")
|
61 |
+
btn = gr.Button("Translate")
|
62 |
+
btn.click(
|
63 |
+
translate,
|
64 |
+
inputs=[input_textbox, source_language_dropdown, target_language_dropdown],
|
65 |
+
outputs=[translated_textbox, info_label]
|
66 |
+
)
|
67 |
+
|
68 |
+
if __name__ == "__main__":
|
69 |
+
demo.launch()
|