Datasets:
File size: 4,416 Bytes
4a1bbb8 |
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 |
"""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"],
}
|