"""DailyDialogue Bengali Dataset""" import os import json import datasets _CITATION = """\ @inproceedings{bhattacharjee-etal-2023-banglanlg, title = "{B}angla{NLG} and {B}angla{T}5: Benchmarks and Resources for Evaluating Low-Resource Natural Language Generation in {B}angla", author = "Bhattacharjee, Abhik and Hasan, Tahmid and Ahmad, Wasi Uddin and Shahriyar, Rifat", booktitle = "Findings of the Association for Computational Linguistics: EACL 2023", month = may, year = "2023", address = "Dubrovnik, Croatia", publisher = "Association for Computational Linguistics", url = "https://aclanthology.org/2023.findings-eacl.54", pages = "726--735", abstract = "This work presents {`}BanglaNLG,{'} a comprehensive benchmark for evaluating natural language generation (NLG) models in Bangla, a widely spoken yet low-resource language. We aggregate six challenging conditional text generation tasks under the BanglaNLG benchmark, introducing a new dataset on dialogue generation in the process. Furthermore, using a clean corpus of 27.5 GB of Bangla data, we pretrain {`}BanglaT5{'}, a sequence-to-sequence Transformer language model for Bangla. BanglaT5 achieves state-of-the-art performance in all of these tasks, outperforming several multilingual models by up to 9{\%} absolute gain and 32{\%} relative gain. We are making the new dialogue dataset and the BanglaT5 model publicly available at https://github.com/csebuetnlp/BanglaNLG in the hope of advancing future research on Bangla NLG.", } """ _DESCRIPTION = """\ DailyDialogue (bengali) has been derived from the original English dataset. """ _HOMEPAGE = "https://github.com/csebuetnlp/BanglaNLG" _LICENSE = "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0)" _URL = "https://huggingface.co/datasets/csebuetnlp/dailydialogue_bn/resolve/main/data/dailydialogue_bn.tar.bz2" _VERSION = datasets.Version("0.0.1") class DailydialogueBn(datasets.GeneratorBasedBuilder): """DailyDialogue Bengali Dataset""" BUILDER_CONFIGS = [ datasets.BuilderConfig( name="dailydialogue_bn", version=_VERSION, description=_DESCRIPTION, ) ] def _info(self): return datasets.DatasetInfo( description=_DESCRIPTION, features=datasets.Features( { "id": datasets.Value("string"), "dialogue": datasets.features.Sequence( datasets.Value("string") ), } ), supervised_keys=None, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION, ) def _split_generators(self, dl_manager): """Returns SplitGenerators.""" data_dir = os.path.join(dl_manager.download_and_extract(_URL), "dailydialogue_bn") return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={ "filepath": os.path.join(data_dir, "train.jsonl"), }, ), datasets.SplitGenerator( name=datasets.Split.TEST, gen_kwargs={ "filepath": os.path.join(data_dir, "test.jsonl"), }, ), datasets.SplitGenerator( name=datasets.Split.VALIDATION, gen_kwargs={ "filepath": os.path.join(data_dir, "validation.jsonl"), }, ), ] def _generate_examples(self, filepath): """Yields examples as (key, example) tuples.""" with open(filepath, encoding="utf-8") as f: for i, line in enumerate(f): data = json.loads(line.strip())['source'] yield i, { "id": str(i), "dialogue": data }