Datasets:
Tasks:
Question Answering
Modalities:
Text
Formats:
parquet
Sub-tasks:
extractive-qa
Languages:
English
Size:
10K - 100K
ArXiv:
License:
Update files from the datasets library (from 1.10.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.10.0
README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
---
|
|
|
2 |
annotations_creators:
|
3 |
- crowdsourced
|
4 |
language_creators:
|
|
|
1 |
---
|
2 |
+
pretty_name: SQuAD
|
3 |
annotations_creators:
|
4 |
- crowdsourced
|
5 |
language_creators:
|
squad.py
CHANGED
@@ -117,28 +117,26 @@ class Squad(datasets.GeneratorBasedBuilder):
|
|
117 |
def _generate_examples(self, filepath):
|
118 |
"""This function returns the examples in the raw (text) form."""
|
119 |
logger.info("generating examples from = %s", filepath)
|
|
|
120 |
with open(filepath, encoding="utf-8") as f:
|
121 |
squad = json.load(f)
|
122 |
for article in squad["data"]:
|
123 |
-
title = article.get("title", "")
|
124 |
for paragraph in article["paragraphs"]:
|
125 |
-
context = paragraph["context"]
|
126 |
for qa in paragraph["qas"]:
|
127 |
-
question = qa["question"].strip()
|
128 |
-
id_ = qa["id"]
|
129 |
-
|
130 |
answer_starts = [answer["answer_start"] for answer in qa["answers"]]
|
131 |
-
answers = [answer["text"]
|
132 |
-
|
133 |
# Features currently used are "context", "question", and "answers".
|
134 |
# Others are extracted here for the ease of future expansions.
|
135 |
-
yield
|
136 |
"title": title,
|
137 |
"context": context,
|
138 |
-
"question": question,
|
139 |
-
"id":
|
140 |
"answers": {
|
141 |
"answer_start": answer_starts,
|
142 |
"text": answers,
|
143 |
},
|
144 |
}
|
|
|
|
117 |
def _generate_examples(self, filepath):
|
118 |
"""This function returns the examples in the raw (text) form."""
|
119 |
logger.info("generating examples from = %s", filepath)
|
120 |
+
key = 0
|
121 |
with open(filepath, encoding="utf-8") as f:
|
122 |
squad = json.load(f)
|
123 |
for article in squad["data"]:
|
124 |
+
title = article.get("title", "")
|
125 |
for paragraph in article["paragraphs"]:
|
126 |
+
context = paragraph["context"] # do not strip leading blank spaces GH-2585
|
127 |
for qa in paragraph["qas"]:
|
|
|
|
|
|
|
128 |
answer_starts = [answer["answer_start"] for answer in qa["answers"]]
|
129 |
+
answers = [answer["text"] for answer in qa["answers"]]
|
|
|
130 |
# Features currently used are "context", "question", and "answers".
|
131 |
# Others are extracted here for the ease of future expansions.
|
132 |
+
yield key, {
|
133 |
"title": title,
|
134 |
"context": context,
|
135 |
+
"question": qa["question"],
|
136 |
+
"id": qa["id"],
|
137 |
"answers": {
|
138 |
"answer_start": answer_starts,
|
139 |
"text": answers,
|
140 |
},
|
141 |
}
|
142 |
+
key += 1
|