|
"""TODO(com_qa): Add a description here.""" |
|
|
|
|
|
import json |
|
|
|
import datasets |
|
|
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{abujabal-etal-2019-comqa, |
|
title = "{ComQA: A Community-sourced Dataset for Complex Factoid Question Answering with Paraphrase Clusters", |
|
author = {Abujabal, Abdalghani and |
|
Saha Roy, Rishiraj and |
|
Yahya, Mohamed and |
|
Weikum, Gerhard}, |
|
booktitle = {Proceedings of the 2019 Conference of the North {A}merican Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers)}, |
|
month = {jun}, |
|
year = {2019}, |
|
address = {Minneapolis, Minnesota}, |
|
publisher = {Association for Computational Linguistics}, |
|
url = {https://www.aclweb.org/anthology/N19-1027}, |
|
doi = {10.18653/v1/N19-1027{, |
|
pages = {307--317}, |
|
} |
|
""" |
|
|
|
|
|
_DESCRIPTION = """\ |
|
ComQA is a dataset of 11,214 questions, which were collected from WikiAnswers, a community question answering website. |
|
By collecting questions from such a site we ensure that the information needs are ones of interest to actual users. |
|
Moreover, questions posed there are often cannot be answered by commercial search engines or QA technology, making them |
|
more interesting for driving future research compared to those collected from an engine's query log. The dataset contains |
|
questions with various challenging phenomena such as the need for temporal reasoning, comparison (e.g., comparatives, |
|
superlatives, ordinals), compositionality (multiple, possibly nested, subquestions with multiple entities), and |
|
unanswerable questions (e.g., Who was the first human being on Mars?). Through a large crowdsourcing effort, questions |
|
in ComQA are grouped into 4,834 paraphrase clusters that express the same information need. Each cluster is annotated |
|
with its answer(s). ComQA answers come in the form of Wikipedia entities wherever possible. Wherever the answers are |
|
temporal or measurable quantities, TIMEX3 and the International System of Units (SI) are used for normalization. |
|
""" |
|
|
|
_URL = "https://qa.mpi-inf.mpg.de/comqa/" |
|
_URLS = { |
|
"train": _URL + "comqa_train.json", |
|
"dev": _URL + "comqa_dev.json", |
|
"test": _URL + "comqa_test.json", |
|
} |
|
|
|
|
|
class ComQa(datasets.GeneratorBasedBuilder): |
|
"""TODO(com_qa): Short description of my dataset.""" |
|
|
|
|
|
VERSION = datasets.Version("0.1.0") |
|
|
|
def _info(self): |
|
|
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=datasets.Features( |
|
{ |
|
"cluster_id": datasets.Value("string"), |
|
"questions": datasets.features.Sequence(datasets.Value("string")), |
|
"answers": datasets.features.Sequence(datasets.Value("string")), |
|
|
|
} |
|
), |
|
|
|
|
|
|
|
supervised_keys=None, |
|
|
|
homepage="http://qa.mpi-inf.mpg.de/comqa/", |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
|
|
|
|
|
|
urls_to_download = _URLS |
|
dl_dir = dl_manager.download_and_extract(urls_to_download) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={"filepath": dl_dir["train"], "split": "train"}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={"filepath": dl_dir["test"], "split": "test"}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={"filepath": dl_dir["dev"], "split": "dev"}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, filepath, split): |
|
"""Yields examples.""" |
|
|
|
with open(filepath, encoding="utf-8") as f: |
|
data = json.load(f) |
|
for id_, example in enumerate(data): |
|
questions = [] |
|
if split == "test": |
|
cluster_id = str(example["id"]) |
|
questions.append(example["question"]) |
|
else: |
|
cluster_id = example["cluster_id"] |
|
questions = example["questions"] |
|
answers = example["answers"] |
|
yield id_, { |
|
"cluster_id": cluster_id, |
|
"questions": questions, |
|
"answers": answers, |
|
} |
|
|