Datasets:
Tasks:
Summarization
Sub-tasks:
news-articles-summarization
Languages:
Dutch
Size:
100K<n<1M
License:
# coding=utf-8 | |
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
"""Cleaned Dutch split of the mC4 corpus.""" | |
import json | |
import datasets | |
logger = datasets.logging.get_logger(__name__) | |
_HOMEPAGE = "https://github.com/abisee/cnn-dailymail" | |
_DESCRIPTION = """\ | |
CNN/DailyMail non-anonymized summarization dataset, translated to Dutch with ccmatrix. | |
There are two features: | |
- article: text of news article, used as the document to be summarized | |
- highlights: joined text of highlights with <s> and </s> around each | |
highlight, which is the target summary | |
""" | |
_LICENSE = "Open Data Commons Attribution License (ODC-By) v1.0" | |
_DATA_URL_NL = "https://huggingface.co/datasets/yhavinga/cnn_dailymail_dutch/resolve/main/{config}/{split}.json.gz" | |
# The second citation introduces the source data, while the first | |
# introduces the specific form (non-anonymized) we use here. | |
_CITATION = """\ | |
@article{DBLP:journals/corr/SeeLM17, | |
author = {Abigail See and | |
Peter J. Liu and | |
Christopher D. Manning}, | |
title = {Get To The Point: Summarization with Pointer-Generator Networks}, | |
journal = {CoRR}, | |
volume = {abs/1704.04368}, | |
year = {2017}, | |
url = {http://arxiv.org/abs/1704.04368}, | |
archivePrefix = {arXiv}, | |
eprint = {1704.04368}, | |
timestamp = {Mon, 13 Aug 2018 16:46:08 +0200}, | |
biburl = {https://dblp.org/rec/bib/journals/corr/SeeLM17}, | |
bibsource = {dblp computer science bibliography, https://dblp.org} | |
} | |
@inproceedings{hermann2015teaching, | |
title={Teaching machines to read and comprehend}, | |
author={Hermann, Karl Moritz and Kocisky, Tomas and Grefenstette, Edward and Espeholt, Lasse and Kay, Will and Suleyman, Mustafa and Blunsom, Phil}, | |
booktitle={Advances in neural information processing systems}, | |
pages={1693--1701}, | |
year={2015} | |
} | |
""" | |
_HIGHLIGHTS = "highlights" | |
_ARTICLE = "article" | |
_SUPPORTED_VERSIONS = [ | |
# Using cased version. | |
datasets.Version("3.0.0", "Using cased version."), | |
] | |
class CnnDailymailDutchConfig(datasets.BuilderConfig): | |
"""BuilderConfig for CnnDailymail Dutch.""" | |
def __init__(self, **kwargs): | |
"""BuilderConfig for CnnDailymail Dutch. | |
Args: | |
**kwargs: keyword arguments forwarded to super. | |
""" | |
super().__init__(**kwargs) | |
class CnnDailymailDutch(datasets.GeneratorBasedBuilder): | |
"""CNN/DailyMail non-anonymized summarization dataset in Dutch.""" | |
BUILDER_CONFIGS = [ | |
CnnDailymailDutchConfig( | |
name=str(version), description=version.description | |
) | |
for version in _SUPPORTED_VERSIONS | |
] | |
def _info(self): | |
return datasets.DatasetInfo( | |
description=_DESCRIPTION, | |
features=datasets.Features( | |
{ | |
_ARTICLE: datasets.Value("string"), | |
_HIGHLIGHTS: datasets.Value("string"), | |
"id": datasets.Value("string"), | |
} | |
), | |
supervised_keys=None, | |
homepage=_HOMEPAGE, | |
license=_LICENSE, | |
citation=_CITATION, | |
) | |
def _split_generators(self, dl_manager): | |
result = [ | |
datasets.SplitGenerator( | |
name=split, | |
gen_kwargs={ | |
"filepath": dl_manager.download_and_extract( | |
_DATA_URL_NL.format(split=str(split), config=str(self.config.name)) | |
) | |
}, | |
) | |
for split in [ | |
datasets.Split.TRAIN, | |
datasets.Split.VALIDATION, | |
datasets.Split.TEST, | |
] | |
] | |
return result | |
def _generate_examples(self, filepath): | |
"""This function returns the examples in the raw (text) form by iterating on all the files.""" | |
logger.info(f"Generating examples from {filepath}") | |
with open(filepath, "r") as file: | |
for _id, line in enumerate(file): | |
example = json.loads(line) | |
yield _id, example | |