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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
"""
|
17 |
+
A parallel corpus of KDE4 localization files. The corpus is available in 92 languages in total, with 4099 bitexts.
|
18 |
+
"""
|
19 |
+
import os
|
20 |
+
from pathlib import Path
|
21 |
+
from typing import Dict, List, Tuple
|
22 |
+
|
23 |
+
import datasets
|
24 |
+
|
25 |
+
from seacrowd.utils import schemas
|
26 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
27 |
+
from seacrowd.utils.constants import Licenses, Tasks
|
28 |
+
|
29 |
+
_CITATION = """\
|
30 |
+
@inproceedings{tiedemann2012parallel,
|
31 |
+
title={Parallel Data, Tools and Interfaces in OPUS},
|
32 |
+
author={Tiedemann, J{\"o}rg},
|
33 |
+
booktitle={Proceedings of the Eighth International Conference on Language Resources and Evaluation (LREC'12)},
|
34 |
+
pages={2214--2218},
|
35 |
+
year={2012}
|
36 |
+
}
|
37 |
+
"""
|
38 |
+
|
39 |
+
_DATASETNAME = "kde4"
|
40 |
+
|
41 |
+
_DESCRIPTION = """\
|
42 |
+
A parallel corpus of KDE4 localization files. The corpus is available in 92 languages in total, with 4099 bitexts.
|
43 |
+
"""
|
44 |
+
|
45 |
+
_HOMEPAGE = "https://opus.nlpl.eu/KDE4/corpus/version/KDE4"
|
46 |
+
|
47 |
+
_LANGUAGES = ["ind", "khm", "zlm", "tha", "vie"]
|
48 |
+
|
49 |
+
_LICENSE = Licenses.UNKNOWN.value
|
50 |
+
_LOCAL = False
|
51 |
+
|
52 |
+
_URL_TEMPLATE = "https://object.pouta.csc.fi/OPUS-KDE4/v2/moses/{src}-{tgt}.txt.zip"
|
53 |
+
|
54 |
+
_SUPPORTED_TASKS = [Tasks.MACHINE_TRANSLATION]
|
55 |
+
_SOURCE_VERSION = "2.0.0"
|
56 |
+
_SEACROWD_VERSION = "2024.06.20"
|
57 |
+
|
58 |
+
kde4_language_codes = {
|
59 |
+
"aar": "aa",
|
60 |
+
"abk": "ab",
|
61 |
+
"ave": "ae",
|
62 |
+
"afr": "af",
|
63 |
+
"aka": "ak",
|
64 |
+
"amh": "am",
|
65 |
+
"arg": "an",
|
66 |
+
"ara": "ar",
|
67 |
+
"asm": "as",
|
68 |
+
"ava": "av",
|
69 |
+
"aym": "ay",
|
70 |
+
"aze": "az",
|
71 |
+
"bak": "ba",
|
72 |
+
"bel": "be",
|
73 |
+
"bul": "bg",
|
74 |
+
"bis": "bi",
|
75 |
+
"bam": "bm",
|
76 |
+
"ben": "bn",
|
77 |
+
"bod": "bo",
|
78 |
+
"bre": "br",
|
79 |
+
"bos": "bs",
|
80 |
+
"cat": "ca",
|
81 |
+
"che": "ce",
|
82 |
+
"cha": "ch",
|
83 |
+
"cos": "co",
|
84 |
+
"cre": "cr",
|
85 |
+
"ces": "cs",
|
86 |
+
"chu": "cu",
|
87 |
+
"chv": "cv",
|
88 |
+
"cym": "cy",
|
89 |
+
"dan": "da",
|
90 |
+
"deu": "de",
|
91 |
+
"div": "dv",
|
92 |
+
"dzo": "dz",
|
93 |
+
"ewe": "ee",
|
94 |
+
"ell": "el",
|
95 |
+
"eng": "en",
|
96 |
+
"epo": "eo",
|
97 |
+
"spa": "es",
|
98 |
+
"est": "et",
|
99 |
+
"eus": "eu",
|
100 |
+
"fas": "fa",
|
101 |
+
"ful": "ff",
|
102 |
+
"fin": "fi",
|
103 |
+
"fij": "fj",
|
104 |
+
"fao": "fo",
|
105 |
+
"fra": "fr",
|
106 |
+
"fry": "fy",
|
107 |
+
"gle": "ga",
|
108 |
+
"gla": "gd",
|
109 |
+
"glg": "gl",
|
110 |
+
"grn": "gn",
|
111 |
+
"guj": "gu",
|
112 |
+
"glv": "gv",
|
113 |
+
"hau": "ha",
|
114 |
+
"heb": "he",
|
115 |
+
"hin": "hi",
|
116 |
+
"hmo": "ho",
|
117 |
+
"hrv": "hr",
|
118 |
+
"hat": "ht",
|
119 |
+
"hun": "hu",
|
120 |
+
"hye": "hy",
|
121 |
+
"her": "hz",
|
122 |
+
"ina": "ia",
|
123 |
+
"ind": "id",
|
124 |
+
"ile": "ie",
|
125 |
+
"ibo": "ig",
|
126 |
+
"iii": "ii",
|
127 |
+
"ipk": "ik",
|
128 |
+
"ido": "io",
|
129 |
+
"isl": "is",
|
130 |
+
"ita": "it",
|
131 |
+
"iku": "iu",
|
132 |
+
"jpn": "ja",
|
133 |
+
"jav": "jv",
|
134 |
+
"kat": "ka",
|
135 |
+
"kon": "kg",
|
136 |
+
"kik": "ki",
|
137 |
+
"kua": "kj",
|
138 |
+
"kaz": "kk",
|
139 |
+
"kal": "kl",
|
140 |
+
"khm": "km",
|
141 |
+
"kan": "kn",
|
142 |
+
"kor": "ko",
|
143 |
+
"kau": "kr",
|
144 |
+
"kas": "ks",
|
145 |
+
"kur": "ku",
|
146 |
+
"kom": "kv",
|
147 |
+
"cor": "kw",
|
148 |
+
"kir": "ky",
|
149 |
+
"lat": "la",
|
150 |
+
"ltz": "lb",
|
151 |
+
"lug": "lg",
|
152 |
+
"lim": "li",
|
153 |
+
"lin": "ln",
|
154 |
+
"lao": "lo",
|
155 |
+
"lit": "lt",
|
156 |
+
"lub": "lu",
|
157 |
+
"lav": "lv",
|
158 |
+
"mlg": "mg",
|
159 |
+
"mah": "mh",
|
160 |
+
"mri": "mi",
|
161 |
+
"mkd": "mk",
|
162 |
+
"mal": "ml",
|
163 |
+
"mon": "mn",
|
164 |
+
"mar": "mr",
|
165 |
+
"msa": "ms",
|
166 |
+
"mlt": "mt",
|
167 |
+
"mya": "my",
|
168 |
+
"nau": "na",
|
169 |
+
"nob": "nb",
|
170 |
+
"nde": "nd",
|
171 |
+
"nep": "ne",
|
172 |
+
"ndo": "ng",
|
173 |
+
"nld": "nl",
|
174 |
+
"nno": "nn",
|
175 |
+
"nor": "no",
|
176 |
+
"nbl": "nr",
|
177 |
+
"nav": "nv",
|
178 |
+
"nya": "ny",
|
179 |
+
"oci": "oc",
|
180 |
+
"oji": "oj",
|
181 |
+
"orm": "om",
|
182 |
+
"ori": "or",
|
183 |
+
"oss": "os",
|
184 |
+
"pan": "pa",
|
185 |
+
"pli": "pi",
|
186 |
+
"pol": "pl",
|
187 |
+
"pus": "ps",
|
188 |
+
"por": "pt",
|
189 |
+
"que": "qu",
|
190 |
+
"roh": "rm",
|
191 |
+
"run": "rn",
|
192 |
+
"ron": "ro",
|
193 |
+
"rus": "ru",
|
194 |
+
"kin": "rw",
|
195 |
+
"san": "sa",
|
196 |
+
"srd": "sc",
|
197 |
+
"snd": "sd",
|
198 |
+
"sme": "se",
|
199 |
+
"sag": "sg",
|
200 |
+
"hbs": "sh",
|
201 |
+
"sin": "si",
|
202 |
+
"slk": "sk",
|
203 |
+
"slv": "sl",
|
204 |
+
"smo": "sm",
|
205 |
+
"sna": "sn",
|
206 |
+
"som": "so",
|
207 |
+
"sqi": "sq",
|
208 |
+
"srp": "sr",
|
209 |
+
"ssw": "ss",
|
210 |
+
"sot": "st",
|
211 |
+
"sun": "su",
|
212 |
+
"swe": "sv",
|
213 |
+
"swa": "sw",
|
214 |
+
"tam": "ta",
|
215 |
+
"tel": "te",
|
216 |
+
"tgk": "tg",
|
217 |
+
"tha": "th",
|
218 |
+
"tir": "ti",
|
219 |
+
"tuk": "tk",
|
220 |
+
"tgl": "tl",
|
221 |
+
"tsn": "tn",
|
222 |
+
"ton": "to",
|
223 |
+
"tur": "tr",
|
224 |
+
"tso": "ts",
|
225 |
+
"tat": "tt",
|
226 |
+
"twi": "tw",
|
227 |
+
"tah": "ty",
|
228 |
+
"uig": "ug",
|
229 |
+
"ukr": "uk",
|
230 |
+
"urd": "ur",
|
231 |
+
"uzb": "uz",
|
232 |
+
"ven": "ve",
|
233 |
+
"vie": "vi",
|
234 |
+
"vol": "vo",
|
235 |
+
"wln": "wa",
|
236 |
+
"wol": "wo",
|
237 |
+
"xho": "xh",
|
238 |
+
"yid": "yi",
|
239 |
+
"yor": "yo",
|
240 |
+
"zha": "za",
|
241 |
+
"zho": "zh",
|
242 |
+
"zul": "zu",
|
243 |
+
"nds": "nds",
|
244 |
+
"mai": "mai",
|
245 |
+
"nso": "nso",
|
246 |
+
"ast": "ast",
|
247 |
+
"crh": "crh",
|
248 |
+
"csb": "csb",
|
249 |
+
"hne": "hne",
|
250 |
+
"hsb": "hsb",
|
251 |
+
}
|
252 |
+
|
253 |
+
configs = {
|
254 |
+
"afr": ["msa", "tha", "khm", "ind", "vie"],
|
255 |
+
"ara": ["msa", "tha", "khm", "ind", "vie"],
|
256 |
+
"asm": ["msa", "tha", "khm", "ind", "vie"],
|
257 |
+
"ast": ["msa", "tha", "khm", "ind", "vie"],
|
258 |
+
"bel": ["msa", "tha", "khm", "ind", "vie"],
|
259 |
+
"bul": ["msa", "tha", "khm", "ind", "vie"],
|
260 |
+
"ben": ["msa", "tha", "khm", "ind", "vie"],
|
261 |
+
"bre": ["msa", "tha", "khm", "ind", "vie"],
|
262 |
+
"cat": ["msa", "tha", "khm", "ind", "vie"],
|
263 |
+
"crh": ["msa", "tha", "khm", "ind", "vie"],
|
264 |
+
"ces": ["msa", "tha", "khm", "ind", "vie"],
|
265 |
+
"csb": ["msa", "tha", "khm", "ind", "vie"],
|
266 |
+
"cym": ["msa", "tha", "khm", "ind", "vie"],
|
267 |
+
"dan": ["msa", "tha", "khm", "ind", "vie"],
|
268 |
+
"deu": ["msa", "tha", "khm", "ind", "vie"],
|
269 |
+
"ell": ["msa", "tha", "khm", "ind", "vie"],
|
270 |
+
"eng": ["msa", "tha", "khm", "ind", "vie"],
|
271 |
+
"epo": ["msa", "tha", "khm", "ind", "vie"],
|
272 |
+
"spa": ["msa", "tha", "khm", "ind", "vie"],
|
273 |
+
"est": ["msa", "tha", "khm", "ind", "vie"],
|
274 |
+
"eus": ["msa", "tha", "khm", "ind", "vie"],
|
275 |
+
"fas": ["msa", "tha", "khm", "ind", "vie"],
|
276 |
+
"fin": ["msa", "tha", "khm", "ind", "vie"],
|
277 |
+
"fra": ["msa", "tha", "khm", "ind", "vie"],
|
278 |
+
"fry": ["msa", "tha", "khm", "ind", "vie"],
|
279 |
+
"gle": ["msa", "tha", "khm", "ind", "vie"],
|
280 |
+
"glg": ["msa", "tha", "khm", "ind", "vie"],
|
281 |
+
"guj": ["msa", "tha", "khm", "ind", "vie"],
|
282 |
+
"hau": ["msa", "tha", "khm", "ind", "vie"],
|
283 |
+
"heb": ["msa", "tha", "khm", "ind", "vie"],
|
284 |
+
"hin": ["msa", "tha", "khm", "ind", "vie"],
|
285 |
+
"hne": ["msa", "tha", "khm", "ind", "vie"],
|
286 |
+
"hrv": ["msa", "tha", "khm", "ind", "vie"],
|
287 |
+
"hsb": ["msa", "tha", "khm", "ind", "vie"],
|
288 |
+
"hun": ["msa", "tha", "khm", "ind", "vie"],
|
289 |
+
"hye": ["msa", "tha", "khm", "ind", "vie"],
|
290 |
+
"ind": [
|
291 |
+
"kan",
|
292 |
+
"pus",
|
293 |
+
"msa",
|
294 |
+
"slv",
|
295 |
+
"tur",
|
296 |
+
"rus",
|
297 |
+
"nld",
|
298 |
+
"mkd",
|
299 |
+
"jpn",
|
300 |
+
"ori",
|
301 |
+
"nep",
|
302 |
+
"xho",
|
303 |
+
"nds",
|
304 |
+
"lav",
|
305 |
+
"ukr",
|
306 |
+
"vie",
|
307 |
+
"mai",
|
308 |
+
"tam",
|
309 |
+
"ltz",
|
310 |
+
"isl",
|
311 |
+
"uzb",
|
312 |
+
"sme",
|
313 |
+
"lit",
|
314 |
+
"tgk",
|
315 |
+
"kat",
|
316 |
+
"mal",
|
317 |
+
"srp",
|
318 |
+
"wln",
|
319 |
+
"por",
|
320 |
+
"oci",
|
321 |
+
"kur",
|
322 |
+
"mar",
|
323 |
+
"sin",
|
324 |
+
"slk",
|
325 |
+
"kor",
|
326 |
+
"kaz",
|
327 |
+
"ron",
|
328 |
+
"nno",
|
329 |
+
"tha",
|
330 |
+
"khm",
|
331 |
+
"tel",
|
332 |
+
"ita",
|
333 |
+
"pol",
|
334 |
+
"swe",
|
335 |
+
"pan",
|
336 |
+
"nob",
|
337 |
+
],
|
338 |
+
"isl": ["khm", "msa", "tha", "vie"],
|
339 |
+
"ita": ["khm", "msa", "tha", "vie"],
|
340 |
+
"jpn": ["khm", "msa", "tha", "vie"],
|
341 |
+
"kat": ["khm", "msa", "tha", "vie"],
|
342 |
+
"kaz": ["khm", "msa", "tha", "vie"],
|
343 |
+
"khm": [
|
344 |
+
"kan",
|
345 |
+
"pus",
|
346 |
+
"msa",
|
347 |
+
"slv",
|
348 |
+
"tur",
|
349 |
+
"rus",
|
350 |
+
"kin",
|
351 |
+
"nld",
|
352 |
+
"mkd",
|
353 |
+
"ori",
|
354 |
+
"xho",
|
355 |
+
"nso",
|
356 |
+
"nep",
|
357 |
+
"nds",
|
358 |
+
"lav",
|
359 |
+
"ukr",
|
360 |
+
"vie",
|
361 |
+
"mai",
|
362 |
+
"tam",
|
363 |
+
"ltz",
|
364 |
+
"uzb",
|
365 |
+
"sme",
|
366 |
+
"lit",
|
367 |
+
"tgk",
|
368 |
+
"mlt",
|
369 |
+
"mal",
|
370 |
+
"srp",
|
371 |
+
"wln",
|
372 |
+
"por",
|
373 |
+
"oci",
|
374 |
+
"kur",
|
375 |
+
"mar",
|
376 |
+
"sin",
|
377 |
+
"slk",
|
378 |
+
"kor",
|
379 |
+
"ron",
|
380 |
+
"nno",
|
381 |
+
"tha",
|
382 |
+
"tel",
|
383 |
+
"pol",
|
384 |
+
"swe",
|
385 |
+
"pan",
|
386 |
+
"nob",
|
387 |
+
],
|
388 |
+
"kan": ["msa", "tha", "vie"],
|
389 |
+
"kor": ["msa", "tha", "vie"],
|
390 |
+
"kur": ["msa", "tha", "vie"],
|
391 |
+
"ltz": ["msa", "tha", "vie"],
|
392 |
+
"lit": ["msa", "tha", "vie"],
|
393 |
+
"lav": ["msa", "tha", "vie"],
|
394 |
+
"mai": ["msa", "tha", "vie"],
|
395 |
+
"mkd": ["msa", "tha", "vie"],
|
396 |
+
"mal": ["msa", "tha", "vie"],
|
397 |
+
"mar": ["msa", "tha", "vie"],
|
398 |
+
"msa": [
|
399 |
+
"pus",
|
400 |
+
"slv",
|
401 |
+
"tur",
|
402 |
+
"rus",
|
403 |
+
"kin",
|
404 |
+
"nld",
|
405 |
+
"ori",
|
406 |
+
"xho",
|
407 |
+
"nso",
|
408 |
+
"nep",
|
409 |
+
"nds",
|
410 |
+
"ukr",
|
411 |
+
"vie",
|
412 |
+
"tam",
|
413 |
+
"uzb",
|
414 |
+
"sme",
|
415 |
+
"tgk",
|
416 |
+
"mlt",
|
417 |
+
"srp",
|
418 |
+
"wln",
|
419 |
+
"por",
|
420 |
+
"oci",
|
421 |
+
"slk",
|
422 |
+
"sin",
|
423 |
+
"ron",
|
424 |
+
"nno",
|
425 |
+
"tha",
|
426 |
+
"tel",
|
427 |
+
"pol",
|
428 |
+
"swe",
|
429 |
+
"pan",
|
430 |
+
"nob",
|
431 |
+
],
|
432 |
+
"mlt": ["tha"],
|
433 |
+
"nob": ["tha", "vie"],
|
434 |
+
"nds": ["tha", "vie"],
|
435 |
+
"nep": ["tha", "vie"],
|
436 |
+
"nld": ["tha", "vie"],
|
437 |
+
"nno": ["tha", "vie"],
|
438 |
+
"oci": ["tha", "vie"],
|
439 |
+
"ori": ["tha", "vie"],
|
440 |
+
"pan": ["tha", "vie"],
|
441 |
+
"pol": ["tha", "vie"],
|
442 |
+
"pus": ["tha", "vie"],
|
443 |
+
"por": ["tha", "vie"],
|
444 |
+
"ron": ["tha", "vie"],
|
445 |
+
"rus": ["tha", "vie"],
|
446 |
+
"kin": ["tha"],
|
447 |
+
"sme": ["tha", "vie"],
|
448 |
+
"sin": ["tha", "vie"],
|
449 |
+
"slk": ["tha", "vie"],
|
450 |
+
"slv": ["tha", "vie"],
|
451 |
+
"srp": ["tha", "vie"],
|
452 |
+
"swe": ["tha", "vie"],
|
453 |
+
"tam": ["tha", "vie"],
|
454 |
+
"tel": ["tha", "vie"],
|
455 |
+
"tgk": ["tha", "vie"],
|
456 |
+
"tha": ["wln", "tur", "uzb", "xho", "vie", "ukr"],
|
457 |
+
"tur": ["vie"],
|
458 |
+
"ukr": ["vie"],
|
459 |
+
"uzb": ["vie"],
|
460 |
+
"vie": ["wln", "xho"],
|
461 |
+
}
|
462 |
+
|
463 |
+
|
464 |
+
class KDE4Dataset(datasets.GeneratorBasedBuilder):
|
465 |
+
"""A parallel corpus of KDE4 localization files. The corpus is available in 92 languages in total, with 4099 bitexts."""
|
466 |
+
|
467 |
+
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
468 |
+
SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
|
469 |
+
|
470 |
+
BUILDER_CONFIGS = (
|
471 |
+
[
|
472 |
+
SEACrowdConfig(
|
473 |
+
name="kde4_source",
|
474 |
+
version=datasets.Version(_SOURCE_VERSION),
|
475 |
+
description="kde4 source schema for afr to msa",
|
476 |
+
schema="source",
|
477 |
+
subset_id="afr_msa",
|
478 |
+
),
|
479 |
+
SEACrowdConfig(
|
480 |
+
name="kde4_seacrowd_t2t",
|
481 |
+
version=datasets.Version(_SOURCE_VERSION),
|
482 |
+
description="kde4 seacrowd_t2t schema for afr to msa",
|
483 |
+
schema="seacrowd_t2t",
|
484 |
+
subset_id="afr_msa",
|
485 |
+
),
|
486 |
+
]
|
487 |
+
+ [
|
488 |
+
SEACrowdConfig(
|
489 |
+
name=f"kde4_{src_lang}_{tgt_lang}_source",
|
490 |
+
version=datasets.Version(_SOURCE_VERSION),
|
491 |
+
description=f"kde4 source schema for {src_lang} to {tgt_lang}",
|
492 |
+
schema="source",
|
493 |
+
subset_id=f"{src_lang}_{tgt_lang}",
|
494 |
+
)
|
495 |
+
for src_lang in configs
|
496 |
+
for tgt_lang in configs[src_lang]
|
497 |
+
]
|
498 |
+
+ [
|
499 |
+
SEACrowdConfig(
|
500 |
+
name=f"kde4_{src_lang}_{tgt_lang}_seacrowd_t2t",
|
501 |
+
version=datasets.Version(_SEACROWD_VERSION),
|
502 |
+
description=f"kde4 seacrowd_t2t schema for {src_lang} to {tgt_lang}",
|
503 |
+
schema="seacrowd_t2t",
|
504 |
+
subset_id=f"{src_lang}_{tgt_lang}",
|
505 |
+
)
|
506 |
+
for src_lang in configs
|
507 |
+
for tgt_lang in configs[src_lang]
|
508 |
+
]
|
509 |
+
)
|
510 |
+
|
511 |
+
DEFAULT_CONFIG_NAME = "kde4_source"
|
512 |
+
|
513 |
+
def _info(self) -> datasets.DatasetInfo:
|
514 |
+
if self.config.schema == "source":
|
515 |
+
features = datasets.Features(
|
516 |
+
{
|
517 |
+
"id": datasets.Value("string"),
|
518 |
+
"src_text": datasets.Value("string"),
|
519 |
+
"tgt_text": datasets.Value("string"),
|
520 |
+
}
|
521 |
+
)
|
522 |
+
|
523 |
+
elif self.config.schema == "seacrowd_t2t":
|
524 |
+
features = schemas.text2text_features
|
525 |
+
|
526 |
+
return datasets.DatasetInfo(
|
527 |
+
description=_DESCRIPTION,
|
528 |
+
features=features,
|
529 |
+
homepage=_HOMEPAGE,
|
530 |
+
license=_LICENSE,
|
531 |
+
citation=_CITATION,
|
532 |
+
)
|
533 |
+
|
534 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
535 |
+
"""Returns SplitGenerators."""
|
536 |
+
|
537 |
+
src_lang, tgt_lang = self.config.subset_id.split("_")
|
538 |
+
kde4_src_lang, kde4_tgt_lang = kde4_language_codes[src_lang], kde4_language_codes[tgt_lang]
|
539 |
+
|
540 |
+
url = _URL_TEMPLATE.format(src=kde4_src_lang, tgt=kde4_tgt_lang)
|
541 |
+
data_dir = dl_manager.download_and_extract(url)
|
542 |
+
|
543 |
+
return [
|
544 |
+
datasets.SplitGenerator(
|
545 |
+
name=datasets.Split.TRAIN,
|
546 |
+
gen_kwargs={
|
547 |
+
"src_lang": src_lang,
|
548 |
+
"tgt_lang": tgt_lang,
|
549 |
+
"src_filepath": os.path.join(data_dir, f"KDE4.{kde4_src_lang}-{kde4_tgt_lang}.{kde4_src_lang}"),
|
550 |
+
"tgt_filepath": os.path.join(data_dir, f"KDE4.{kde4_src_lang}-{kde4_tgt_lang}.{kde4_tgt_lang}"),
|
551 |
+
},
|
552 |
+
)
|
553 |
+
]
|
554 |
+
|
555 |
+
def _generate_examples(self, src_lang: str, tgt_lang: str, src_filepath: Path, tgt_filepath: Path) -> Tuple[int, Dict]:
|
556 |
+
"""Yields examples as (key, example) tuples."""
|
557 |
+
|
558 |
+
if self.config.schema == "source":
|
559 |
+
for row_id, (src_text, tgt_text) in enumerate(zip(open(src_filepath), open(tgt_filepath))):
|
560 |
+
yield row_id, {
|
561 |
+
"id": row_id,
|
562 |
+
"src_text": src_text.strip(),
|
563 |
+
"tgt_text": tgt_text.strip(),
|
564 |
+
}
|
565 |
+
|
566 |
+
elif self.config.schema == "seacrowd_t2t":
|
567 |
+
for row_id, (src_text, tgt_text) in enumerate(zip(open(src_filepath), open(tgt_filepath))):
|
568 |
+
yield row_id, {
|
569 |
+
"id": row_id,
|
570 |
+
"text_1": src_text.strip(),
|
571 |
+
"text_2": tgt_text.strip(),
|
572 |
+
"text_1_name": src_lang,
|
573 |
+
"text_2_name": tgt_lang,
|
574 |
+
}
|