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: qasc
|
|
|
1 |
---
|
2 |
+
pretty_name: Question Answering via Sentence Composition (QASC)
|
3 |
languages:
|
4 |
- en
|
5 |
paperswithcode_id: qasc
|
qasc.py
CHANGED
@@ -2,7 +2,6 @@
|
|
2 |
|
3 |
|
4 |
import json
|
5 |
-
import os
|
6 |
|
7 |
import datasets
|
8 |
|
@@ -66,49 +65,59 @@ class Qasc(datasets.GeneratorBasedBuilder):
|
|
66 |
# TODO(qasc): Downloads the data and defines the splits
|
67 |
# dl_manager is a datasets.download.DownloadManager that can be used to
|
68 |
# download and extract URLs
|
69 |
-
|
70 |
-
data_dir = os.path.join(dl_dir, "QASC_Dataset")
|
71 |
return [
|
72 |
datasets.SplitGenerator(
|
73 |
name=datasets.Split.TRAIN,
|
74 |
# These kwargs will be passed to _generate_examples
|
75 |
-
gen_kwargs={
|
|
|
|
|
|
|
76 |
),
|
77 |
datasets.SplitGenerator(
|
78 |
name=datasets.Split.TEST,
|
79 |
# These kwargs will be passed to _generate_examples
|
80 |
-
gen_kwargs={
|
|
|
|
|
|
|
81 |
),
|
82 |
datasets.SplitGenerator(
|
83 |
name=datasets.Split.VALIDATION,
|
84 |
# These kwargs will be passed to _generate_examples
|
85 |
-
gen_kwargs={
|
|
|
|
|
|
|
86 |
),
|
87 |
]
|
88 |
|
89 |
-
def _generate_examples(self, filepath):
|
90 |
"""Yields examples."""
|
91 |
# TODO(qasc): Yields (key, example) tuples from the dataset
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
2 |
|
3 |
|
4 |
import json
|
|
|
5 |
|
6 |
import datasets
|
7 |
|
|
|
65 |
# TODO(qasc): Downloads the data and defines the splits
|
66 |
# dl_manager is a datasets.download.DownloadManager that can be used to
|
67 |
# download and extract URLs
|
68 |
+
archive = dl_manager.download(_URl)
|
|
|
69 |
return [
|
70 |
datasets.SplitGenerator(
|
71 |
name=datasets.Split.TRAIN,
|
72 |
# These kwargs will be passed to _generate_examples
|
73 |
+
gen_kwargs={
|
74 |
+
"filepath": "/".join(["QASC_Dataset", "train.jsonl"]),
|
75 |
+
"files": dl_manager.iter_archive(archive),
|
76 |
+
},
|
77 |
),
|
78 |
datasets.SplitGenerator(
|
79 |
name=datasets.Split.TEST,
|
80 |
# These kwargs will be passed to _generate_examples
|
81 |
+
gen_kwargs={
|
82 |
+
"filepath": "/".join(["QASC_Dataset", "test.jsonl"]),
|
83 |
+
"files": dl_manager.iter_archive(archive),
|
84 |
+
},
|
85 |
),
|
86 |
datasets.SplitGenerator(
|
87 |
name=datasets.Split.VALIDATION,
|
88 |
# These kwargs will be passed to _generate_examples
|
89 |
+
gen_kwargs={
|
90 |
+
"filepath": "/".join(["QASC_Dataset", "dev.jsonl"]),
|
91 |
+
"files": dl_manager.iter_archive(archive),
|
92 |
+
},
|
93 |
),
|
94 |
]
|
95 |
|
96 |
+
def _generate_examples(self, filepath, files):
|
97 |
"""Yields examples."""
|
98 |
# TODO(qasc): Yields (key, example) tuples from the dataset
|
99 |
+
for path, f in files:
|
100 |
+
if path == filepath:
|
101 |
+
for row in f:
|
102 |
+
data = json.loads(row.decode("utf-8"))
|
103 |
+
answerkey = data.get("answerKey", "")
|
104 |
+
id_ = data["id"]
|
105 |
+
question = data["question"]["stem"]
|
106 |
+
choices = data["question"]["choices"]
|
107 |
+
text_choices = [choice["text"] for choice in choices]
|
108 |
+
label_choices = [choice["label"] for choice in choices]
|
109 |
+
fact1 = data.get("fact1", "")
|
110 |
+
fact2 = data.get("fact2", "")
|
111 |
+
combined_fact = data.get("combinedfact", "")
|
112 |
+
formatted_question = data.get("formatted_question", "")
|
113 |
+
yield id_, {
|
114 |
+
"id": id_,
|
115 |
+
"answerKey": answerkey,
|
116 |
+
"question": question,
|
117 |
+
"choices": {"text": text_choices, "label": label_choices},
|
118 |
+
"fact1": fact1,
|
119 |
+
"fact2": fact2,
|
120 |
+
"combinedfact": combined_fact,
|
121 |
+
"formatted_question": formatted_question,
|
122 |
+
}
|
123 |
+
break
|