Datasets:
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
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
languages:
|
| 3 |
- en
|
| 4 |
paperswithcode_id: mlqa
|
|
|
|
| 1 |
---
|
| 2 |
+
pretty_name: MLQA (MultiLingual Question Answering)
|
| 3 |
languages:
|
| 4 |
- en
|
| 5 |
paperswithcode_id: mlqa
|
mlqa.py
CHANGED
|
@@ -117,27 +117,23 @@ class Mlqa(datasets.GeneratorBasedBuilder):
|
|
| 117 |
# dl_manager is a datasets.download.DownloadManager that can be used to
|
| 118 |
# download and extract URLs
|
| 119 |
if self.config.name.startswith("mlqa-translate-train"):
|
| 120 |
-
|
| 121 |
lang = self.config.name.split(".")[-1]
|
| 122 |
return [
|
| 123 |
datasets.SplitGenerator(
|
| 124 |
name=datasets.Split.TRAIN,
|
| 125 |
# These kwargs will be passed to _generate_examples
|
| 126 |
gen_kwargs={
|
| 127 |
-
"filepath":
|
| 128 |
-
|
| 129 |
-
"{}_squad-translate-train-train-v1.1.json".format(lang),
|
| 130 |
-
)
|
| 131 |
},
|
| 132 |
),
|
| 133 |
datasets.SplitGenerator(
|
| 134 |
name=datasets.Split.VALIDATION,
|
| 135 |
# These kwargs will be passed to _generate_examples
|
| 136 |
gen_kwargs={
|
| 137 |
-
"filepath":
|
| 138 |
-
|
| 139 |
-
"{}_squad-translate-train-dev-v1.1.json".format(lang),
|
| 140 |
-
)
|
| 141 |
},
|
| 142 |
),
|
| 143 |
]
|
|
@@ -154,7 +150,7 @@ class Mlqa(datasets.GeneratorBasedBuilder):
|
|
| 154 |
gen_kwargs={
|
| 155 |
"filepath": os.path.join(
|
| 156 |
os.path.join(dl_file, "MLQA_V1/test"),
|
| 157 |
-
"test-context-{}-question-{}.json"
|
| 158 |
)
|
| 159 |
},
|
| 160 |
),
|
|
@@ -163,33 +159,36 @@ class Mlqa(datasets.GeneratorBasedBuilder):
|
|
| 163 |
# These kwargs will be passed to _generate_examples
|
| 164 |
gen_kwargs={
|
| 165 |
"filepath": os.path.join(
|
| 166 |
-
os.path.join(dl_file, "MLQA_V1/dev"), "dev-context-{}-question-{}.json"
|
| 167 |
)
|
| 168 |
},
|
| 169 |
),
|
| 170 |
]
|
| 171 |
else:
|
| 172 |
if self.config.name.startswith("mlqa-translate-test"):
|
| 173 |
-
|
| 174 |
lang = self.config.name.split(".")[-1]
|
| 175 |
return [
|
| 176 |
datasets.SplitGenerator(
|
| 177 |
name=datasets.Split.TEST,
|
| 178 |
# These kwargs will be passed to _generate_examples
|
| 179 |
gen_kwargs={
|
| 180 |
-
"filepath":
|
| 181 |
-
|
| 182 |
-
"translate-test-context-{}-question-{}.json".format(lang, lang),
|
| 183 |
-
)
|
| 184 |
},
|
| 185 |
),
|
| 186 |
]
|
| 187 |
|
| 188 |
-
def _generate_examples(self, filepath):
|
| 189 |
"""Yields examples."""
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
for examples in data["data"]:
|
| 194 |
for example in examples["paragraphs"]:
|
| 195 |
context = example["context"]
|
|
|
|
| 117 |
# dl_manager is a datasets.download.DownloadManager that can be used to
|
| 118 |
# download and extract URLs
|
| 119 |
if self.config.name.startswith("mlqa-translate-train"):
|
| 120 |
+
archive = dl_manager.download(self.config.data_url)
|
| 121 |
lang = self.config.name.split(".")[-1]
|
| 122 |
return [
|
| 123 |
datasets.SplitGenerator(
|
| 124 |
name=datasets.Split.TRAIN,
|
| 125 |
# These kwargs will be passed to _generate_examples
|
| 126 |
gen_kwargs={
|
| 127 |
+
"filepath": f"mlqa-translate-train/{lang}_squad-translate-train-train-v1.1.json",
|
| 128 |
+
"files": dl_manager.iter_archive(archive),
|
|
|
|
|
|
|
| 129 |
},
|
| 130 |
),
|
| 131 |
datasets.SplitGenerator(
|
| 132 |
name=datasets.Split.VALIDATION,
|
| 133 |
# These kwargs will be passed to _generate_examples
|
| 134 |
gen_kwargs={
|
| 135 |
+
"filepath": f"mlqa-translate-train/{lang}_squad-translate-train-dev-v1.1.json",
|
| 136 |
+
"files": dl_manager.iter_archive(archive),
|
|
|
|
|
|
|
| 137 |
},
|
| 138 |
),
|
| 139 |
]
|
|
|
|
| 150 |
gen_kwargs={
|
| 151 |
"filepath": os.path.join(
|
| 152 |
os.path.join(dl_file, "MLQA_V1/test"),
|
| 153 |
+
f"test-context-{l1}-question-{l2}.json",
|
| 154 |
)
|
| 155 |
},
|
| 156 |
),
|
|
|
|
| 159 |
# These kwargs will be passed to _generate_examples
|
| 160 |
gen_kwargs={
|
| 161 |
"filepath": os.path.join(
|
| 162 |
+
os.path.join(dl_file, "MLQA_V1/dev"), f"dev-context-{l1}-question-{l2}.json"
|
| 163 |
)
|
| 164 |
},
|
| 165 |
),
|
| 166 |
]
|
| 167 |
else:
|
| 168 |
if self.config.name.startswith("mlqa-translate-test"):
|
| 169 |
+
archive = dl_manager.download(self.config.data_url)
|
| 170 |
lang = self.config.name.split(".")[-1]
|
| 171 |
return [
|
| 172 |
datasets.SplitGenerator(
|
| 173 |
name=datasets.Split.TEST,
|
| 174 |
# These kwargs will be passed to _generate_examples
|
| 175 |
gen_kwargs={
|
| 176 |
+
"filepath": f"mlqa-translate-test/translate-test-context-{lang}-question-{lang}.json",
|
| 177 |
+
"files": dl_manager.iter_archive(archive),
|
|
|
|
|
|
|
| 178 |
},
|
| 179 |
),
|
| 180 |
]
|
| 181 |
|
| 182 |
+
def _generate_examples(self, filepath, files=None):
|
| 183 |
"""Yields examples."""
|
| 184 |
+
if self.config.name.startswith("mlqa-translate"):
|
| 185 |
+
for path, f in files:
|
| 186 |
+
if path == filepath:
|
| 187 |
+
data = json.loads(f.read().decode("utf-8"))
|
| 188 |
+
break
|
| 189 |
+
else:
|
| 190 |
+
with open(filepath, encoding="utf-8") as f:
|
| 191 |
+
data = json.load(f)
|
| 192 |
for examples in data["data"]:
|
| 193 |
for example in examples["paragraphs"]:
|
| 194 |
context = example["context"]
|