Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions datasets/adversarial_qa/adversarial_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,14 @@ def _generate_examples(self, filepath, split, model_in_the_loop):
logger.info("generating examples from = %s", filepath)
with open(filepath, encoding="utf-8") as f:
squad = json.load(f)
id_ = 0
for article in squad["data"]:
title = article.get("title", "").strip()
for paragraph in article["paragraphs"]:
context = paragraph["context"].strip()
for qa in paragraph["qas"]:
question = qa["question"].strip()
id_ = qa["id"]
qid = qa["id"]

answer_starts = [answer["answer_start"] for answer in qa["answers"]]
answers = [answer["text"].strip() for answer in qa["answers"]]
Expand All @@ -188,10 +189,12 @@ def _generate_examples(self, filepath, split, model_in_the_loop):
"title": title,
"context": context,
"question": question,
"id": id_,
"id": qid,
"answers": {
"answer_start": answer_starts,
"text": answers,
},
"metadata": {"split": split, "model_in_the_loop": model_in_the_loop},
}

id_ += 1