Commit
•
49aad53
1
Parent(s):
b33c264
Support streaming iwslt2017 dataset (#4992)
Browse filesCommit from https://github.com/huggingface/datasets/commit/5b7cc0b1ceae98b9791e9df102ee279fabedd469
- iwslt2017.py +12 -21
iwslt2017.py
CHANGED
@@ -20,6 +20,12 @@ import os
|
|
20 |
import datasets
|
21 |
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
_CITATION = """\
|
24 |
@inproceedings{cettolo-etal-2017-overview,
|
25 |
title = "Overview of the {IWSLT} 2017 Evaluation Campaign",
|
@@ -41,11 +47,9 @@ _CITATION = """\
|
|
41 |
}
|
42 |
"""
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
""
|
47 |
-
|
48 |
-
MULTI_URL = "https://huggingface.co/datasets/iwslt2017/resolve/ebd7c60d9800c2a1be010a227e5f0a2363730f7a/data/2017-01-trnmted/texts/DeEnItNlRo/DeEnItNlRo/DeEnItNlRo-DeEnItNlRo.tgz"
|
49 |
|
50 |
|
51 |
class IWSLT2017Config(datasets.BuilderConfig):
|
@@ -100,18 +104,11 @@ class IWSLT217(datasets.GeneratorBasedBuilder):
|
|
100 |
|
101 |
def _info(self):
|
102 |
return datasets.DatasetInfo(
|
103 |
-
# This is the description that will appear on the datasets page.
|
104 |
description=_DESCRIPTION,
|
105 |
-
# datasets.features.FeatureConnectors
|
106 |
features=datasets.Features(
|
107 |
{"translation": datasets.features.Translation(languages=self.config.pair.split("-"))}
|
108 |
),
|
109 |
-
|
110 |
-
# specify them here. They'll be used if as_supervised=True in
|
111 |
-
# builder.as_dataset.
|
112 |
-
supervised_keys=None,
|
113 |
-
# Homepage of the dataset for documentation
|
114 |
-
homepage="https://sites.google.com/site/iwsltevaluation2017/TED-tasks",
|
115 |
citation=_CITATION,
|
116 |
)
|
117 |
|
@@ -123,14 +120,13 @@ class IWSLT217(datasets.GeneratorBasedBuilder):
|
|
123 |
data_dir = os.path.join(dl_dir, "DeEnItNlRo-DeEnItNlRo")
|
124 |
years = [2010]
|
125 |
else:
|
126 |
-
bi_url =
|
127 |
dl_dir = dl_manager.download_and_extract(bi_url)
|
128 |
data_dir = os.path.join(dl_dir, f"{source}-{target}")
|
129 |
years = [2010, 2011, 2012, 2013, 2014, 2015]
|
130 |
return [
|
131 |
datasets.SplitGenerator(
|
132 |
name=datasets.Split.TRAIN,
|
133 |
-
# These kwargs will be passed to _generate_examples
|
134 |
gen_kwargs={
|
135 |
"source_files": [
|
136 |
os.path.join(
|
@@ -144,12 +140,10 @@ class IWSLT217(datasets.GeneratorBasedBuilder):
|
|
144 |
f"train.tags.{self.config.pair}.{target}",
|
145 |
)
|
146 |
],
|
147 |
-
"split": "train",
|
148 |
},
|
149 |
),
|
150 |
datasets.SplitGenerator(
|
151 |
name=datasets.Split.TEST,
|
152 |
-
# These kwargs will be passed to _generate_examples
|
153 |
gen_kwargs={
|
154 |
"source_files": [
|
155 |
os.path.join(
|
@@ -165,12 +159,10 @@ class IWSLT217(datasets.GeneratorBasedBuilder):
|
|
165 |
)
|
166 |
for year in years
|
167 |
],
|
168 |
-
"split": "test",
|
169 |
},
|
170 |
),
|
171 |
datasets.SplitGenerator(
|
172 |
name=datasets.Split.VALIDATION,
|
173 |
-
# These kwargs will be passed to _generate_examples
|
174 |
gen_kwargs={
|
175 |
"source_files": [
|
176 |
os.path.join(
|
@@ -184,12 +176,11 @@ class IWSLT217(datasets.GeneratorBasedBuilder):
|
|
184 |
f"IWSLT17.TED.dev2010.{self.config.pair}.{target}.xml",
|
185 |
)
|
186 |
],
|
187 |
-
"split": "dev",
|
188 |
},
|
189 |
),
|
190 |
]
|
191 |
|
192 |
-
def _generate_examples(self, source_files, target_files
|
193 |
"""Yields examples."""
|
194 |
id_ = 0
|
195 |
source, target = self.config.pair.split("-")
|
|
|
20 |
import datasets
|
21 |
|
22 |
|
23 |
+
_HOMEPAGE = "https://sites.google.com/site/iwsltevaluation2017/TED-tasks"
|
24 |
+
|
25 |
+
_DESCRIPTION = """\
|
26 |
+
The IWSLT 2017 Multilingual Task addresses text translation, including zero-shot translation, with a single MT system across all directions including English, German, Dutch, Italian and Romanian. As unofficial task, conventional bilingual text translation is offered between English and Arabic, French, Japanese, Chinese, German and Korean.
|
27 |
+
"""
|
28 |
+
|
29 |
_CITATION = """\
|
30 |
@inproceedings{cettolo-etal-2017-overview,
|
31 |
title = "Overview of the {IWSLT} 2017 Evaluation Campaign",
|
|
|
47 |
}
|
48 |
"""
|
49 |
|
50 |
+
REPO_URL = "https://huggingface.co/datasets/iwslt2017/resolve/main/"
|
51 |
+
MULTI_URL = REPO_URL + "data/2017-01-trnmted/texts/DeEnItNlRo/DeEnItNlRo/DeEnItNlRo-DeEnItNlRo.zip"
|
52 |
+
BI_URL = REPO_URL + "data/2017-01-trnted/texts/{source}/{target}/{source}-{target}.zip"
|
|
|
|
|
53 |
|
54 |
|
55 |
class IWSLT2017Config(datasets.BuilderConfig):
|
|
|
104 |
|
105 |
def _info(self):
|
106 |
return datasets.DatasetInfo(
|
|
|
107 |
description=_DESCRIPTION,
|
|
|
108 |
features=datasets.Features(
|
109 |
{"translation": datasets.features.Translation(languages=self.config.pair.split("-"))}
|
110 |
),
|
111 |
+
homepage=_HOMEPAGE,
|
|
|
|
|
|
|
|
|
|
|
112 |
citation=_CITATION,
|
113 |
)
|
114 |
|
|
|
120 |
data_dir = os.path.join(dl_dir, "DeEnItNlRo-DeEnItNlRo")
|
121 |
years = [2010]
|
122 |
else:
|
123 |
+
bi_url = BI_URL.format(source=source, target=target)
|
124 |
dl_dir = dl_manager.download_and_extract(bi_url)
|
125 |
data_dir = os.path.join(dl_dir, f"{source}-{target}")
|
126 |
years = [2010, 2011, 2012, 2013, 2014, 2015]
|
127 |
return [
|
128 |
datasets.SplitGenerator(
|
129 |
name=datasets.Split.TRAIN,
|
|
|
130 |
gen_kwargs={
|
131 |
"source_files": [
|
132 |
os.path.join(
|
|
|
140 |
f"train.tags.{self.config.pair}.{target}",
|
141 |
)
|
142 |
],
|
|
|
143 |
},
|
144 |
),
|
145 |
datasets.SplitGenerator(
|
146 |
name=datasets.Split.TEST,
|
|
|
147 |
gen_kwargs={
|
148 |
"source_files": [
|
149 |
os.path.join(
|
|
|
159 |
)
|
160 |
for year in years
|
161 |
],
|
|
|
162 |
},
|
163 |
),
|
164 |
datasets.SplitGenerator(
|
165 |
name=datasets.Split.VALIDATION,
|
|
|
166 |
gen_kwargs={
|
167 |
"source_files": [
|
168 |
os.path.join(
|
|
|
176 |
f"IWSLT17.TED.dev2010.{self.config.pair}.{target}.xml",
|
177 |
)
|
178 |
],
|
|
|
179 |
},
|
180 |
),
|
181 |
]
|
182 |
|
183 |
+
def _generate_examples(self, source_files, target_files):
|
184 |
"""Yields examples."""
|
185 |
id_ = 0
|
186 |
source, target = self.config.pair.split("-")
|