swahili-safi / swahili-safi.py
fgaim's picture
Add missing param
c7f049b
raw
history blame
2.09 kB
"""Cleaned dataset for Swahili Language Modeling"""
import datasets
_CITATION = """\
@InProceedings{huggingface:flax-community,
title = Cleaned dataset for Swahili Language Modeling,
authors={Fitsum, Alok, Patrick},
year={2021},
link = https://huggingface.co/datasets/flax-community/swahili-safi
}
"""
_DESCRIPTION = """Cleaned dataset for Swahili Language Modeling"""
_HOMEPAGE = "https://huggingface.co/datasets/flax-community/swahili-safi"
_LICENSE = "Attribution 4.0 International"
_REPO_URL = "https://huggingface.co/datasets/flax-community/swahili-safi/resolve/main/"
_TRAIN= [_REPO_URL + file_name for file_name in [
"data/train.txt",
]]
class SwahiliSafi(datasets.GeneratorBasedBuilder):
"""The Swahili dataset for language modeling"""
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="swahili-safi",
version=VERSION,
description="Language modeling dataset for Swahili"
),
]
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"text": datasets.Value("string"),
}
),
supervised_keys=None,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
train_files = dl_manager.download(_TRAIN)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"data_files": train_files,
"split": "train",
},
)
]
def _generate_examples(self, data_files, split):
"""Yields examples."""
_id = 0
for filepath in data_files:
with open(filepath, mode="r", encoding="utf-8") as f:
for line in f:
yield _id, {"text": line.strip()},
_id += 1