|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""TODO: Add a description here.""" |
|
|
|
|
|
import csv |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{perez2019generating, |
|
title={Generating Summaries with Topic Templates and Structured Convolutional Decoders}, |
|
author={Perez-Beltrachini, Laura and Liu, Yang and Lapata, Mirella}, |
|
booktitle={Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics}, |
|
pages={5107--5116}, |
|
year={2019} |
|
} |
|
""" |
|
|
|
|
|
|
|
_DESCRIPTION = """\ |
|
Summarise the most important facts of a given entity in the Film, Company, and Animal domains from a cluster of related documents. |
|
""" |
|
|
|
|
|
_HOMEPAGE = "https://datashare.ed.ac.uk/handle/10283/3368" |
|
|
|
|
|
_LICENSE = "CC BY-SA 3.0" |
|
|
|
|
|
|
|
|
|
_URLs = { |
|
"animal": { |
|
"train": "./main_splits/train-animal.jsonl", |
|
"validation": "./main_splits/valid-animal.jsonl", |
|
"test": "./main_splits/test-animal.jsonl", |
|
"cs_abs":[ |
|
"./cs_abs/test-animal_nv_0.jsonl", |
|
"./cs_abs/test-animal_nv_1.jsonl", |
|
"./cs_abs/test-animal_nv_2.jsonl", |
|
"./cs_abs/test-animal_nv_3.jsonl", |
|
"./cs_abs/test-animal_nv_4.jsonl", |
|
"./cs_abs/test-animal_nv_6.jsonl", |
|
"./cs_abs/test-animal_nv_7.jsonl", |
|
"./cs_abs/test-animal_nv_8.jsonl", |
|
"./cs_abs/test-animal_nv_9.jsonl", |
|
], |
|
"cs_tdiv": [ |
|
"./cs_tdiv/test-animal_tdiv_0.jsonl", |
|
"./cs_tdiv/test-animal_tdiv_1.jsonl", |
|
"./cs_tdiv/test-animal_tdiv_2.jsonl", |
|
"./cs_tdiv/test-animal_tdiv_3.jsonl", |
|
] |
|
}, |
|
"company": { |
|
"train": "./main_splits/train-company.jsonl", |
|
"validation": "./main_splits/valid-company.jsonl", |
|
"test": "./main_splits/test-company.jsonl", |
|
"cs_abs":[ |
|
"./cs_abs/test-company_nv_0.jsonl", |
|
"./cs_abs/test-company_nv_1.jsonl", |
|
"./cs_abs/test-company_nv_2.jsonl", |
|
"./cs_abs/test-company_nv_3.jsonl", |
|
"./cs_abs/test-company_nv_4.jsonl", |
|
"./cs_abs/test-company_nv_6.jsonl", |
|
"./cs_abs/test-company_nv_7.jsonl", |
|
"./cs_abs/test-company_nv_8.jsonl", |
|
"./cs_abs/test-company_nv_9.jsonl", |
|
], |
|
"cs_tdiv": [ |
|
"./cs_tdiv/test-company_tdiv_0.jsonl", |
|
"./cs_tdiv/test-company_tdiv_1.jsonl", |
|
"./cs_tdiv/test-company_tdiv_2.jsonl", |
|
"./cs_tdiv/test-company_tdiv_3.jsonl", |
|
] |
|
}, |
|
"film": { |
|
"train": "./film/train-film.jsonl", |
|
"validation": "./film/valid-film.jsonl", |
|
"test": "./film/test-film.jsonl", |
|
"cs_abs":[ |
|
"./cs_abs/test-film_nv_0.jsonl", |
|
"./cs_abs/test-film_nv_1.jsonl", |
|
"./cs_abs/test-film_nv_2.jsonl", |
|
"./cs_abs/test-film_nv_3.jsonl", |
|
"./cs_abs/test-film_nv_4.jsonl", |
|
"./cs_abs/test-film_nv_6.jsonl", |
|
"./cs_abs/test-film_nv_7.jsonl", |
|
"./cs_abs/test-film_nv_8.jsonl", |
|
"./cs_abs/test-film_nv_9.jsonl", |
|
], |
|
"cs_tdiv": [ |
|
"./cs_tdiv/test-film_tdiv_0.jsonl", |
|
"./cs_tdiv/test-film_tdiv_1.jsonl", |
|
"./cs_tdiv/test-film_tdiv_2.jsonl", |
|
"./cs_tdiv/test-film_tdiv_3.jsonl", |
|
] |
|
} |
|
} |
|
|
|
|
|
|
|
class WikiCatSum(datasets.GeneratorBasedBuilder): |
|
"""TODO: Short description of my dataset.""" |
|
|
|
VERSION = datasets.Version("0.1.0") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="animal" , version=VERSION, description="Animal domain"), |
|
datasets.BuilderConfig(name="company", version=VERSION, description="Company domain"), |
|
datasets.BuilderConfig(name="film" , version=VERSION, description="Film domain"), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "animal" |
|
|
|
def _info(self): |
|
|
|
features = datasets.Features( |
|
{ |
|
"gem_id": datasets.Value("string"), |
|
"gem_parent_id": datasets.Value("string"), |
|
"id": datasets.Value("string"), |
|
"title": datasets.Value("string"), |
|
"paragraphs": datasets.features.Sequence( |
|
datasets.Value("string")), |
|
"summary": datasets.features.Sequence( |
|
{ |
|
"text": datasets.Value("string"), |
|
"topic": datasets.Value("int16"), |
|
}) |
|
|
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
supervised_keys=None, |
|
|
|
homepage=_HOMEPAGE, |
|
|
|
license=_LICENSE, |
|
|
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
my_urls = _URLs[self.config.name] |
|
d_conf = dl_manager.download_and_extract(my_urls) |
|
challenge_sets = [ |
|
("challenge_test_abstractivity_%d" % (lvl), fname) \ |
|
for lvl,fname in enumerate(d_conf["cs_abs"]) |
|
] + [ |
|
("challenge_test_topic_diversity_%d" % (lvl),d_conf["cs_tdiv"]["test-%s_tdiv_%d.jsonl" % (self.config.name,lvl)]) \ |
|
for lvl in range(4) |
|
] |
|
|
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filepath": d_conf["train"], |
|
"split": "train", |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"filepath": d_conf["validation"], |
|
"split": "test" |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"filepath": d_conf["test"], |
|
"split": "validation", |
|
}, |
|
), |
|
] + [ |
|
datasets.SplitGenerator( |
|
name=challenge_split, |
|
gen_kwargs={ |
|
"filepath": filename, |
|
"split": challenge_split, |
|
}, |
|
) |
|
for challenge_split, filename in challenge_sets |
|
] |
|
|
|
def _generate_examples( |
|
self, filepath, split |
|
): |
|
""" Yields examples as (key, example) tuples. """ |
|
|
|
|
|
|
|
with open(filepath, encoding="utf-8") as f: |
|
for id_, row in enumerate(f): |
|
data = json.loads(row) |
|
|
|
|
|
data["gem_parent_id"] = f"{self.config.name}-{split}-{id_+1}" |
|
data["gem_id"] = f"{self.config.name}-{split}-{id_+1}" |
|
yield id_,data |
|
|