|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Dataset loading script for loading the Large-Scale-QASRL (FitzGeralds et. al., ACL 2018) training set, along with the QASRL-GS evaluation dataset (Roit et. al., ACL 2020).""" |
|
|
|
|
|
import datasets |
|
from pathlib import Path |
|
import gzip |
|
import json |
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{fitzgerald2018large, |
|
title={Large-Scale QA-SRL Parsing}, |
|
author={FitzGerald, Nicholas and Michael, Julian and He, Luheng and Zettlemoyer, Luke}, |
|
booktitle={Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)}, |
|
pages={2051--2060}, |
|
year={2018} |
|
} |
|
@inproceedings{roit2020controlled, |
|
title={Controlled Crowdsourcing for High-Quality QA-SRL Annotation}, |
|
author={Roit, Paul and Klein, Ayal and Stepanov, Daniela and Mamou, Jonathan and Michael, Julian and Stanovsky, Gabriel and Zettlemoyer, Luke and Dagan, Ido}, |
|
booktitle={Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics}, |
|
pages={7008--7013}, |
|
year={2020} |
|
} |
|
""" |
|
|
|
|
|
_DESCRIPTION = """\ |
|
The dataset contains question-answer pairs to model verbal predicate-argument structure. |
|
The questions start with wh-words (Who, What, Where, What, etc.) and contain a verb predicate in the sentence; the answers are phrases in the sentence. |
|
This dataset loads the train split from "QASRL Bank", a.k.a "QASRL-v2" or "QASRL-LS" (Large Scale), |
|
which was constructed via crowdsourcing and presented at (FitzGeralds et. al., ACL 2018), |
|
and the dev and test splits from QASRL-GS (Gold Standard), introduced in (Roit et. al., ACL 2020). |
|
""" |
|
|
|
_HOMEPAGE = "https://qasrl.org" |
|
|
|
|
|
_LICENSE = "" |
|
|
|
SpanFeatureType = datasets.Sequence(datasets.Value("int32"), length=2) |
|
|
|
|
|
class QaSrl(datasets.GeneratorBasedBuilder): |
|
"""QA-SRL: Question-Answer Driven Semantic Role Labeling corpus""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig( |
|
name="plain_text", version=VERSION, description="" |
|
), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = ( |
|
"plain_text" |
|
) |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"sentence": datasets.Value("string"), |
|
"sent_id": datasets.Value("string"), |
|
"predicate_idx": datasets.Value("int32"), |
|
"predicate": datasets.Value("string"), |
|
"is_verbal": datasets.Value("bool"), |
|
"verb_form": datasets.Value("string"), |
|
"question": datasets.Sequence(datasets.Value("string")), |
|
"answers": datasets.Sequence(datasets.Value("string")), |
|
"answer_ranges": datasets.Sequence(SpanFeatureType) |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
supervised_keys=None, |
|
|
|
homepage=_HOMEPAGE, |
|
|
|
license=_LICENSE, |
|
|
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager: datasets.utils.download_manager.DownloadManager): |
|
"""Returns SplitGenerators.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.qasrl2018 = datasets.load_dataset("biu-nlp/qa_srl2018") |
|
self.qasrl2020 = datasets.load_dataset("biu-nlp/qa_srl2020") |
|
|
|
|
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"dataset": self.qasrl2018["train"], |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"dataset": self.qasrl2020["validation"], |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"dataset": self.qasrl2020["test"], |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, dataset): |
|
|
|
""" Yields examples from a '.jsonl.gz' file .""" |
|
for idx, instance in enumerate(dataset): |
|
yield idx, instance |
|
|
|
|