khalidalt commited on
Commit
620c255
1 Parent(s): 9988619

Update tydiqa-goldp.py

Browse files
Files changed (1) hide show
  1. tydiqa-goldp.py +4 -24
tydiqa-goldp.py CHANGED
@@ -101,30 +101,10 @@ class tydiqa_GoldP(datasets.GeneratorBasedBuilder):
101
 
102
  with open(filepath, encoding="utf-8") as f:
103
  for row in f:
104
- print("Here:")
105
- print(row)
 
106
  #assert False
107
  #data = json.load(f)
108
  #for article in data["data"]:
109
- title = article.get("title", "").strip()
110
- for paragraph in article["paragraphs"]:
111
- context = paragraph["context"].strip()
112
- for qa in paragraph["qas"]:
113
- question = qa["question"].strip()
114
- id_ = qa["id"]
115
-
116
- answer_starts = [answer["answer_start"] for answer in qa["answers"]]
117
- answers = [answer["text"].strip() for answer in qa["answers"]]
118
-
119
- # Features currently used are "context", "question", and "answers".
120
- # Others are extracted here for the ease of future expansions.
121
- yield id_, {
122
- "title": title,
123
- "context": context,
124
- "question": question,
125
- "id": id_,
126
- "answers": {
127
- "answer_start": answer_starts,
128
- "text": answers,
129
- },
130
- }
 
101
 
102
  with open(filepath, encoding="utf-8") as f:
103
  for row in f:
104
+ data = json.loads(row)
105
+ id = data["id"]
106
+ yield id, data
107
  #assert False
108
  #data = json.load(f)
109
  #for article in data["data"]:
110
+