Update files from the datasets library (from 1.16.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.16.0
- README.md +1 -0
- ted_multi.py +34 -20
README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
---
|
|
|
2 |
paperswithcode_id: null
|
3 |
---
|
4 |
|
|
|
1 |
---
|
2 |
+
pretty_name: TEDMulti
|
3 |
paperswithcode_id: null
|
4 |
---
|
5 |
|
ted_multi.py
CHANGED
@@ -17,7 +17,6 @@
|
|
17 |
"""TED talk multilingual data set."""
|
18 |
|
19 |
import csv
|
20 |
-
import os
|
21 |
|
22 |
import datasets
|
23 |
|
@@ -134,36 +133,51 @@ class TedMultiTranslate(datasets.GeneratorBasedBuilder):
|
|
134 |
)
|
135 |
|
136 |
def _split_generators(self, dl_manager):
|
137 |
-
|
138 |
|
139 |
return [
|
140 |
datasets.SplitGenerator(
|
141 |
-
name=datasets.Split.TRAIN,
|
|
|
|
|
|
|
|
|
142 |
),
|
143 |
datasets.SplitGenerator(
|
144 |
-
name=datasets.Split.VALIDATION,
|
|
|
|
|
|
|
|
|
145 |
),
|
146 |
datasets.SplitGenerator(
|
147 |
-
name=datasets.Split.TEST,
|
|
|
|
|
|
|
|
|
148 |
),
|
149 |
]
|
150 |
|
151 |
-
def _generate_examples(self, data_file):
|
152 |
"""This function returns the examples in the raw (text) form."""
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
"
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
167 |
|
168 |
|
169 |
def _is_translation_complete(text):
|
|
|
17 |
"""TED talk multilingual data set."""
|
18 |
|
19 |
import csv
|
|
|
20 |
|
21 |
import datasets
|
22 |
|
|
|
133 |
)
|
134 |
|
135 |
def _split_generators(self, dl_manager):
|
136 |
+
archive = dl_manager.download(_DATA_URL)
|
137 |
|
138 |
return [
|
139 |
datasets.SplitGenerator(
|
140 |
+
name=datasets.Split.TRAIN,
|
141 |
+
gen_kwargs={
|
142 |
+
"data_file": "all_talks_train.tsv",
|
143 |
+
"files": dl_manager.iter_archive(archive),
|
144 |
+
},
|
145 |
),
|
146 |
datasets.SplitGenerator(
|
147 |
+
name=datasets.Split.VALIDATION,
|
148 |
+
gen_kwargs={
|
149 |
+
"data_file": "all_talks_dev.tsv",
|
150 |
+
"files": dl_manager.iter_archive(archive),
|
151 |
+
},
|
152 |
),
|
153 |
datasets.SplitGenerator(
|
154 |
+
name=datasets.Split.TEST,
|
155 |
+
gen_kwargs={
|
156 |
+
"data_file": "all_talks_test.tsv",
|
157 |
+
"files": dl_manager.iter_archive(archive),
|
158 |
+
},
|
159 |
),
|
160 |
]
|
161 |
|
162 |
+
def _generate_examples(self, data_file, files):
|
163 |
"""This function returns the examples in the raw (text) form."""
|
164 |
+
for path, f in files:
|
165 |
+
if path == data_file:
|
166 |
+
lines = (line.decode("utf-8") for line in f)
|
167 |
+
reader = csv.DictReader(lines, delimiter="\t", quoting=csv.QUOTE_NONE)
|
168 |
+
for idx, row in enumerate(reader):
|
169 |
+
# Everything in the row except for 'talk_name' will be a translation.
|
170 |
+
# Missing/incomplete translations will contain the string "__NULL__" or
|
171 |
+
# "_ _ NULL _ _".
|
172 |
+
yield idx, {
|
173 |
+
"translations": {
|
174 |
+
lang: text
|
175 |
+
for lang, text in row.items()
|
176 |
+
if lang != "talk_name" and _is_translation_complete(text)
|
177 |
+
},
|
178 |
+
"talk_name": row["talk_name"],
|
179 |
+
}
|
180 |
+
break
|
181 |
|
182 |
|
183 |
def _is_translation_complete(text):
|