"""TODO: Add a description here.""" import csv import json import os import datasets # TODO: Add BibTeX citation # Find for instance the citation on arxiv or on the dataset repo/website _CITATION = """\ @dataset{marivate_vukosi_2023_7598540, author = {Marivate, Vukosi and Njini, Daniel and Madodonga, Andani and Lastrucci, Richard and Dzingirai, Isheanesu Rajab, Jenalea}, title = {The Vuk'uzenzele South African Multilingual Corpus}, month = feb, year = 2023, publisher = {Zenodo}, doi = {10.5281/zenodo.7598539}, url = {https://doi.org/10.5281/zenodo.7598539} } """ _DESCRIPTION = """\ The dataset contains editions from the South African government magazine Vuk'uzenzele. Data was scraped from PDFs that have been placed in the data/raw folder. The PDFS were obtained from the Vuk'uzenzele website. """ # TODO: Add a link to an official homepage for the dataset here _HOMEPAGE = "https://arxiv.org/abs/2303.03750" # TODO: Add the licence for the dataset here if you can find it _LICENSE = "CC 4.0 BY" _URL = "https://raw.githubusercontent.com/dsfsi/vukuzenzele-nlp/master/data/huggingface/" _DATAFILE = "data.jsonl" class VukuzenzeleMonolingualConfig(datasets.BuilderConfig): """BuilderConfig for VukuzenzeleMonolingual""" def __init__(self, **kwargs): """BuilderConfig for Masakhaner. Args: **kwargs: keyword arguments forwarded to super. """ super(VukuzenzeleMonolingualConfig, self).__init__(**kwargs) # TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case class VukuzenzeleMonolingual(datasets.GeneratorBasedBuilder): """TODO: Short description of my dataset.""" VERSION = datasets.Version("1.0.0") BUILDER_CONFIGS = [ datasets.BuilderConfig(name="afr", version=VERSION, description="Vukuzenzele Afrikaans Dataset"), datasets.BuilderConfig(name="eng", version=VERSION, description="Vukuzenzele English Dataset"), datasets.BuilderConfig(name="nbl", version=VERSION, description="Vukuzenzele Ndebele Dataset"), datasets.BuilderConfig(name="nso", version=VERSION, description="Vukuzenzele Sepedi Dataset"), datasets.BuilderConfig(name="sot", version=VERSION, description="Vukuzenzele Sesotho Dataset"), datasets.BuilderConfig(name="ssw", version=VERSION, description="Vukuzenzele siSwati Dataset"), datasets.BuilderConfig(name="tsn", version=VERSION, description="Vukuzenzele Setswana Dataset"), datasets.BuilderConfig(name="tso", version=VERSION, description="Vukuzenzele Xitsonga Dataset"), datasets.BuilderConfig(name="ven", version=VERSION, description="Vukuzenzele Tshivenda Dataset"), datasets.BuilderConfig(name="xho", version=VERSION, description="Vukuzenzele isiXhosa Dataset"), datasets.BuilderConfig(name="zul", version=VERSION, description="Vukuzenzele isiZulu Dataset"), ] def _info(self): features = datasets.Features( { "title": datasets.Value("string"), "text": datasets.Value("string"), "language_code": datasets.Value("string"), "edition": datasets.Value("string") } ) return datasets.DatasetInfo( description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, # Citation for the dataset citation=_CITATION, ) def _split_generators(self, dl_manager): urls = { "train": f"{_URL}{self.config.name}/{_DATAFILE}" } data_dir = dl_manager.download_and_extract(urls) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={ "filepath": data_dir["train"], "split": "train", }, ), ] def _generate_examples(self, filepath, split): with open(filepath, encoding="utf-8") as f: for key, row in enumerate(f): data = json.loads(row) if 'title' not in data.keys(): continue yield key, { "title": data["title"], "text": data["text"], "edition": data["edition"], "language_code": data["language_code"], }