Datasets:
Tasks:
Question Answering
Modalities:
Text
Sub-tasks:
extractive-qa
Languages:
English
Size:
10K - 100K
ArXiv:
License:
Update qa_squad.py
Browse files- qa_squad.py +9 -23
qa_squad.py
CHANGED
@@ -4,7 +4,7 @@ from datasets.tasks import QuestionAnsweringExtractive
|
|
4 |
|
5 |
|
6 |
logger = datasets.logging.get_logger(__name__)
|
7 |
-
_VERSION = "0.0.
|
8 |
_NAME = "qa_squad"
|
9 |
_DESCRIPTION = """SQuAD with the train/validation/test split used in SQuAD QG"""
|
10 |
_CITATION = """
|
@@ -75,27 +75,13 @@ class QASquad(datasets.GeneratorBasedBuilder):
|
|
75 |
|
76 |
def _generate_examples(self, filepath):
|
77 |
"""This function returns the examples in the raw (text) form."""
|
|
|
78 |
logger.info("generating examples from = %s", filepath)
|
79 |
-
key = 0
|
80 |
with open(filepath, encoding="utf-8") as f:
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
answers = [answer["text"] for answer in qa["answers"]]
|
89 |
-
# Features currently used are "context", "question", and "answers".
|
90 |
-
# Others are extracted here for the ease of future expansions.
|
91 |
-
yield key, {
|
92 |
-
"title": title,
|
93 |
-
"context": context,
|
94 |
-
"question": qa["question"],
|
95 |
-
"id": qa["id"],
|
96 |
-
"answers": {
|
97 |
-
"answer_start": answer_starts,
|
98 |
-
"text": answers,
|
99 |
-
},
|
100 |
-
}
|
101 |
-
key += 1
|
|
|
4 |
|
5 |
|
6 |
logger = datasets.logging.get_logger(__name__)
|
7 |
+
_VERSION = "0.0.2"
|
8 |
_NAME = "qa_squad"
|
9 |
_DESCRIPTION = """SQuAD with the train/validation/test split used in SQuAD QG"""
|
10 |
_CITATION = """
|
|
|
75 |
|
76 |
def _generate_examples(self, filepath):
|
77 |
"""This function returns the examples in the raw (text) form."""
|
78 |
+
_key = 0
|
79 |
logger.info("generating examples from = %s", filepath)
|
|
|
80 |
with open(filepath, encoding="utf-8") as f:
|
81 |
+
_list = f.read().split('\n')
|
82 |
+
if _list[-1] == '':
|
83 |
+
_list = _list[:-1]
|
84 |
+
for i in _list:
|
85 |
+
data = json.loads(i)
|
86 |
+
yield _key, data
|
87 |
+
_key += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|