Datasets:
sd
Browse files
poquad.py
CHANGED
@@ -45,7 +45,7 @@ class SquadV2(datasets.GeneratorBasedBuilder):
|
|
45 |
|
46 |
# TODO(squad_v2): Set up version.
|
47 |
BUILDER_CONFIGS = [
|
48 |
-
SquadV2Config(name="poquad", version=datasets.Version("2.0.
|
49 |
]
|
50 |
|
51 |
def _info(self):
|
@@ -98,7 +98,7 @@ class SquadV2(datasets.GeneratorBasedBuilder):
|
|
98 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
99 |
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
100 |
datasets.SplitGenerator(name="testA", gen_kwargs={"filepath": downloaded_files["test-A"]}),
|
101 |
-
datasets.SplitGenerator(name=
|
102 |
]
|
103 |
|
104 |
def _generate_examples(self, filepath):
|
@@ -110,20 +110,22 @@ class SquadV2(datasets.GeneratorBasedBuilder):
|
|
110 |
for example in squad["data"]:
|
111 |
title = example.get("title", "")
|
112 |
summary = example.get("summary", "")
|
113 |
-
|
114 |
-
for paragraph in example["paragraphs"]:
|
115 |
context = paragraph["context"] # do not strip leading blank spaces GH-2585
|
116 |
-
for qa in paragraph["qas"]:
|
117 |
question = qa["question"]
|
118 |
id_ += 1
|
119 |
|
|
|
|
|
120 |
if "answers" in qa:
|
121 |
answers_key="answers"
|
122 |
elif "plausible_answers" in qa:
|
123 |
answers_key="plausible_answers"
|
124 |
else:
|
125 |
-
yield
|
126 |
-
"id":
|
127 |
"title": title,
|
128 |
"summary": summary,
|
129 |
"context": context,
|
@@ -145,8 +147,8 @@ class SquadV2(datasets.GeneratorBasedBuilder):
|
|
145 |
# Features currently used are "context", "question", and "answers".
|
146 |
# Others are extracted here for the ease of future expansions.
|
147 |
|
148 |
-
yield
|
149 |
-
"id":
|
150 |
"title": title,
|
151 |
"summary": summary,
|
152 |
"context": context,
|
|
|
45 |
|
46 |
# TODO(squad_v2): Set up version.
|
47 |
BUILDER_CONFIGS = [
|
48 |
+
SquadV2Config(name="poquad", version=datasets.Version("2.0.4"), description="PoQuaD plaint text"),
|
49 |
]
|
50 |
|
51 |
def _info(self):
|
|
|
98 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
99 |
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
100 |
datasets.SplitGenerator(name="testA", gen_kwargs={"filepath": downloaded_files["test-A"]}),
|
101 |
+
datasets.SplitGenerator(name="testB", gen_kwargs={"filepath": downloaded_files["test-B"]}),
|
102 |
]
|
103 |
|
104 |
def _generate_examples(self, filepath):
|
|
|
110 |
for example in squad["data"]:
|
111 |
title = example.get("title", "")
|
112 |
summary = example.get("summary", "")
|
113 |
+
example_id = example["id"]
|
114 |
+
for paragraph_id, paragraph in enumerate(example["paragraphs"]):
|
115 |
context = paragraph["context"] # do not strip leading blank spaces GH-2585
|
116 |
+
for question_id,qa in enumerate(paragraph["qas"]):
|
117 |
question = qa["question"]
|
118 |
id_ += 1
|
119 |
|
120 |
+
idd = f"{example_id}_{paragraph_id}_{question_id}"
|
121 |
+
|
122 |
if "answers" in qa:
|
123 |
answers_key="answers"
|
124 |
elif "plausible_answers" in qa:
|
125 |
answers_key="plausible_answers"
|
126 |
else:
|
127 |
+
yield idd, {
|
128 |
+
"id": idd,
|
129 |
"title": title,
|
130 |
"summary": summary,
|
131 |
"context": context,
|
|
|
147 |
# Features currently used are "context", "question", and "answers".
|
148 |
# Others are extracted here for the ease of future expansions.
|
149 |
|
150 |
+
yield idd, {
|
151 |
+
"id": idd,
|
152 |
"title": title,
|
153 |
"summary": summary,
|
154 |
"context": context,
|