File size: 4,858 Bytes
16f84e6 8c7cfa6 16f84e6 b59185c 16f84e6 b59185c 8c7cfa6 16f84e6 8c7cfa6 16f84e6 7c257e9 8c7cfa6 16f84e6 7c257e9 8c7cfa6 16f84e6 7c257e9 8c7cfa6 16f84e6 7c257e9 16f84e6 8c7cfa6 7c257e9 8c7cfa6 911f635 8c7cfa6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
"""XL-Sum abstractive summarization dataset."""
import json
import os
import datasets
_CITATION = """\
@inproceedings{hasan-etal-2021-xl,
title = "{XL}-Sum: Large-Scale Multilingual Abstractive Summarization for 44 Languages",
author = "Hasan, Tahmid and
Bhattacharjee, Abhik and
Islam, Md. Saiful and
Mubasshir, Kazi and
Li, Yuan-Fang and
Kang, Yong-Bin and
Rahman, M. Sohel and
Shahriyar, Rifat",
booktitle = "Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021",
month = aug,
year = "2021",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2021.findings-acl.413",
pages = "4693--4703",
}
"""
_DESCRIPTION = """\
We present XLSum, a comprehensive and diverse dataset comprising 1.35 million professionally
annotated article-summary pairs from BBC, extracted using a set of carefully designed heuristics.
The dataset covers 45 languages ranging from low to high-resource, for many of which no
public dataset is currently available. XL-Sum is highly abstractive, concise,
and of high quality, as indicated by human and intrinsic evaluation.
"""
_HOMEPAGE = "https://github.com/csebuetnlp/xl-sum"
_LICENSE = "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0)"
_DATA_PATH = "data/{}_XLSum_v{}.tar.bz2" # relative path to the data
_LANGUAGES = [
"oromo",
"french",
"amharic",
"arabic",
"azerbaijani",
"bengali",
"burmese",
"chinese_simplified",
"chinese_traditional",
"welsh",
"english",
"kirundi",
"gujarati",
"hausa",
"hindi",
"igbo",
"indonesian",
"japanese",
"korean",
"kyrgyz",
"marathi",
"spanish",
"scottish_gaelic",
"nepali",
"pashto",
"persian",
"pidgin",
"portuguese",
"punjabi",
"russian",
"serbian_cyrillic",
"serbian_latin",
"sinhala",
"somali",
"swahili",
"tamil",
"telugu",
"thai",
"tigrinya",
"turkish",
"ukrainian",
"urdu",
"uzbek",
"vietnamese",
"yoruba",
]
class Xlsum(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("2.0.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="{}".format(lang),
version=datasets.Version("2.0.0")
)
for lang in _LANGUAGES
]
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"id": datasets.Value("string"),
"url": datasets.Value("string"),
"title": datasets.Value("string"),
"summary": datasets.Value("string"),
"text": datasets.Value("string"),
}
),
supervised_keys=None,
homepage=_HOMEPAGE,
citation=_CITATION,
license=_LICENSE,
version=self.VERSION,
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
lang = str(self.config.name)
data_path = _DATA_PATH.format(lang, self.VERSION.version_str[:-2])
# we download and use dl_manager.iter_archive to be able to load the dataset in streaming mode
archive = dl_manager.download(data_path)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"filename": lang + "_train.jsonl",
"files": dl_manager.iter_archive(archive),
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"filename": lang + "_test.jsonl",
"files": dl_manager.iter_archive(archive),
},
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
gen_kwargs={
"filename": lang + "_val.jsonl",
"files": dl_manager.iter_archive(archive),
},
),
]
def _generate_examples(self, filename, files):
"""Yields examples as (key, example) tuples."""
for path, f in files:
if os.path.basename(path) == filename:
for idx_, row in enumerate(f):
data = json.loads(row.decode("utf-8"))
yield idx_, {
"id": data["id"],
"url": data["url"],
"title": data["title"],
"summary": data["summary"],
"text": data["text"],
}
break
|