dhivehi-corpus / dhivehi-corpus.py
import datasets
_CITATION = """\
@InProceedings{huggingface:dataset,
title = {A great new dataset},
author={huggingface, Inc.
},
year={2021}
}
"""
_DESCRIPTION = """\
This is a dataset put together to pretrain a language model in Dhivehi, the language of Maldives.
"""
_HOMEPAGE = "https://huggingface.co/datasets/ashraq/dhivehi-corpus"
_LICENSE = ""
TRAIN_URL = "train.txt"
class DhivehiCorpus(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.1.0")
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"text": datasets.Value("string"),
},
),
supervised_keys=None,
homepage=_HOMEPAGE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
train_path = dl_manager.download_and_extract(TRAIN_URL)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"filepath": train_path,
"split": "train",
},
),
]
def _generate_examples(self, filepath, split):
with open(filepath, encoding="utf8") as f:
id_ = 0
for line in f:
yield id_, {"text": line.strip()}
id_ += 1