|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""A Dataset loading script for the QA-Align dataset (Brook Weiss et. al., EMNLP 2021).""" |
|
|
|
|
|
import datasets |
|
from pathlib import Path |
|
from typing import List |
|
import pandas as pd |
|
import json |
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{brook-weiss-etal-2021-qa, |
|
title = "{QA}-Align: Representing Cross-Text Content Overlap by Aligning Question-Answer Propositions", |
|
author = "Brook Weiss, Daniela and |
|
Roit, Paul and |
|
Klein, Ayal and |
|
Ernst, Ori and |
|
Dagan, Ido", |
|
booktitle = "Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing", |
|
month = nov, |
|
year = "2021", |
|
address = "Online and Punta Cana, Dominican Republic", |
|
publisher = "Association for Computational Linguistics", |
|
url = "https://aclanthology.org/2021.emnlp-main.778", |
|
pages = "9879--9894", |
|
abstract = "Multi-text applications, such as multi-document summarization, are typically required to model redundancies across related texts. Current methods confronting consolidation struggle to fuse overlapping information. In order to explicitly represent content overlap, we propose to align predicate-argument relations across texts, providing a potential scaffold for information consolidation. We go beyond clustering coreferring mentions, and instead model overlap with respect to redundancy at a propositional level, rather than merely detecting shared referents. Our setting exploits QA-SRL, utilizing question-answer pairs to capture predicate-argument relations, facilitating laymen annotation of cross-text alignments. We employ crowd-workers for constructing a dataset of QA-based alignments, and present a baseline QA alignment model trained over our dataset. Analyses show that our new task is semantically challenging, capturing content overlap beyond lexical similarity and complements cross-document coreference with proposition-level links, offering potential use for downstream tasks.", |
|
}""" |
|
|
|
|
|
_DESCRIPTION = """\ |
|
This dataset contains QA-Alignments - annotations of cross-text content overlap. |
|
The task input is two sentences from two documents, roughly talking about the same event, along with their QA-SRL annotations |
|
which capture verbal predicate-argument relations in question-answer format. The output is a cross-sentence alignment between sets of QAs which denote the same information. |
|
See the paper for details: QA-Align: Representing Cross-Text Content Overlap by Aligning Question-Answer Propositions, Brook Weiss et. al., EMNLP 2021. |
|
Here we provide both the QASRL annotations and the QA-Align annotations for the target sentences. |
|
""" |
|
|
|
_HOMEPAGE = "https://github.com/DanielaBWeiss/QA-ALIGN" |
|
|
|
_LICENSE = """Resources on this page are licensed CC-BY 4.0, a Creative Commons license requiring Attribution (https://creativecommons.org/licenses/by/4.0/).""" |
|
|
|
|
|
_URLs = { |
|
"train": "https://github.com/DanielaBWeiss/QA-ALIGN/raw/master/data/official_qa_alignments/qaalign_train_silver_official.csv", |
|
"dev": "https://github.com/DanielaBWeiss/QA-ALIGN/raw/master/data/official_qa_alignments/qaalign_dev_gold_official.csv", |
|
"test": "https://github.com/DanielaBWeiss/QA-ALIGN/raw/master/data/official_qa_alignments/qaalign_test_gold_official.csv", |
|
} |
|
|
|
|
|
class QaAlign(datasets.GeneratorBasedBuilder): |
|
"""QA-Align: Representing Cross-Text Content Overlap by Aligning Question-Answer Propositions. """ |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig( |
|
name="plain_text", version=VERSION, description="This provides the QA-Align dataset" |
|
), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = ( |
|
"plain_text" |
|
) |
|
|
|
def _info(self): |
|
|
|
|
|
features = datasets.Features( |
|
{ |
|
"text_1": datasets.Value("string"), |
|
"text_2": datasets.Value("string"), |
|
"prev_text_2": datasets.Value("string"), |
|
"prev_text_1": datasets.Value("string"), |
|
"abs_sent_id_2": datasets.Value("string"), |
|
"abs_sent_id_1": datasets.Value("string"), |
|
"qas_1": dict, |
|
"qas_2": dict, |
|
"alignments": dict, |
|
} |
|
) |
|
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.""" |
|
|
|
|
|
corpora = {section: Path(dl_manager.download_and_extract(_URLs[section])) |
|
for section in _URLs} |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filepath": corpora["train"] |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"filepath": corpora["dev"] |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"filepath": corpora["test"] |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, filepath: List[str]): |
|
|
|
""" Yields QA-Align examples from a csv file. Each instance contains all the alignment for a pair of sentences. """ |
|
|
|
|
|
df = pd.read_csv(filepath) |
|
for counter, dic in enumerate(df.to_dict('records')): |
|
columns_to_load_into_object = ["qas_1", "qas_2", "alignments"] |
|
for key in columns_to_load_into_object: |
|
dic[key] = json.loads(dic[key]) |
|
columns_to_remove = ["worker_id","assignment_id","work_time_in_seconds", "year","topic","key","source","source-data","tokens_1","tokens_2"] |
|
for key in columns_to_remove: |
|
del dic[key] |
|
yield counter, dic |
|
|