Datasets:
lmqg
/

Sub-tasks:
extractive-qa
Languages:
English
Multilinguality:
monolingual
Size Categories:
1M<
Source Datasets:
extended|wikipedia
ArXiv:
Tags:
License:
asahi417 commited on
Commit
eb3287b
1 Parent(s): 248bb63

Update qa_squad.py

Browse files
Files changed (1) hide show
  1. 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.1"
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
- squad = json.load(f)
82
- for article in squad["data"]:
83
- title = article.get("title", "")
84
- for paragraph in article["paragraphs"]:
85
- context = paragraph["context"] # do not strip leading blank spaces GH-2585
86
- for qa in paragraph["qas"]:
87
- answer_starts = [answer["answer_start"] for answer in qa["answers"]]
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