Datasets:
Delete bayelemabaga.py
#1
by
Makan09
- opened
- bayelemabaga.py +0 -131
bayelemabaga.py
DELETED
|
@@ -1,131 +0,0 @@
|
|
| 1 |
-
""" RobotsMaliAI: Bayelemaba """
|
| 2 |
-
|
| 3 |
-
import datasets
|
| 4 |
-
|
| 5 |
-
_CITATION = """\
|
| 6 |
-
@misc{bayelemabagamldataset2022
|
| 7 |
-
title={Machine Learning Dataset Development for Manding Languages},
|
| 8 |
-
author={
|
| 9 |
-
Valentin Vydrin and
|
| 10 |
-
Christopher Homan and
|
| 11 |
-
Michael Leventhal and
|
| 12 |
-
Allashera Auguste Tapo and
|
| 13 |
-
Marco Zampieri and
|
| 14 |
-
Jean-Jacques Meric and
|
| 15 |
-
Kirill Maslinsky and
|
| 16 |
-
Andrij Rovenchak and
|
| 17 |
-
Sebastien Diarra
|
| 18 |
-
|
| 19 |
-
},
|
| 20 |
-
howpublished = {url{https://github.com/robotsmali-ai/datasets}},
|
| 21 |
-
year={2022}
|
| 22 |
-
}
|
| 23 |
-
"""
|
| 24 |
-
|
| 25 |
-
_DESCRIPTION = """\
|
| 26 |
-
The Bayelemabaga dataset is a collection of 44160 aligned machine translation ready Bambara-French lines,
|
| 27 |
-
originating from Corpus Bambara de Reference. The dataset is constitued of text extracted from 231 source files,
|
| 28 |
-
varing from periodicals, books, short stories, blog posts, part of the Bible and the Quran.
|
| 29 |
-
"""
|
| 30 |
-
|
| 31 |
-
_URL = {
|
| 32 |
-
"parallel": "https://robotsmali-ai.github.io/datasets/bayelemabaga.tar.gz"
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
_LanguagePairs = [
|
| 36 |
-
"bam-fr", "fr-bam"]
|
| 37 |
-
|
| 38 |
-
class BayelemabagaConfig(datasets.BuilderConfig):
|
| 39 |
-
""" BuilderConfig for Bayelemabaga """
|
| 40 |
-
|
| 41 |
-
def __init__(self, language_pair, **kwargs) -> None:
|
| 42 |
-
"""
|
| 43 |
-
Args:
|
| 44 |
-
language_pair: language pair, you want to load
|
| 45 |
-
**kwargs: -> Super()
|
| 46 |
-
"""
|
| 47 |
-
super().__init__(**kwargs)
|
| 48 |
-
|
| 49 |
-
self.language_pair = language_pair
|
| 50 |
-
|
| 51 |
-
class Bayelemabaga(datasets.GeneratorBasedBuilder):
|
| 52 |
-
""" Bi-Lingual Bam, Fr text made for Machine Translation """
|
| 53 |
-
|
| 54 |
-
VERSION = datasets.Version("1.0.0")
|
| 55 |
-
BUILDER_CONFIG_CLASS = BayelemabagaConfig
|
| 56 |
-
|
| 57 |
-
BUILDER_CONFIGS = [
|
| 58 |
-
BayelemabagaConfig(name="bam-fr", description=_DESCRIPTION, language_pair="bam-fr"),
|
| 59 |
-
BayelemabagaConfig(name="fr-bam", description=_DESCRIPTION, language_pair="fr-bam")
|
| 60 |
-
]
|
| 61 |
-
|
| 62 |
-
def _info(self):
|
| 63 |
-
src_tag, tgt_tag = self.config.language_pair.split("-")
|
| 64 |
-
return datasets.DatasetInfo(
|
| 65 |
-
description=_DESCRIPTION,
|
| 66 |
-
features=datasets.Features({"translation": datasets.features.Translation(languages=(src_tag, tgt_tag))}),
|
| 67 |
-
supervised_keys=(src_tag, tgt_tag),
|
| 68 |
-
homepage="https://robotsmali-ai.github.io/datasets",
|
| 69 |
-
citation=_CITATION
|
| 70 |
-
)
|
| 71 |
-
|
| 72 |
-
def _split_generators(self, dl_manager):
|
| 73 |
-
lang_pair = self.config.language_pair
|
| 74 |
-
src_tag, tgt_tag = lang_pair.split("-")
|
| 75 |
-
|
| 76 |
-
archive = dl_manager.download(_URL["parallel"])
|
| 77 |
-
|
| 78 |
-
train_dir = "bayelemabaga/train"
|
| 79 |
-
valid_dir = "bayelemabaga/valid"
|
| 80 |
-
test_dir = "bayelemabaga/test"
|
| 81 |
-
|
| 82 |
-
train = datasets.SplitGenerator(
|
| 83 |
-
name=datasets.Split.TRAIN,
|
| 84 |
-
gen_kwargs = {
|
| 85 |
-
"filepath": f"{train_dir}/train.{src_tag}",
|
| 86 |
-
"labelpath": f"{train_dir}/train.{tgt_tag}",
|
| 87 |
-
"files": dl_manager.iter_archive(archive)
|
| 88 |
-
}
|
| 89 |
-
)
|
| 90 |
-
|
| 91 |
-
valid = datasets.SplitGenerator(
|
| 92 |
-
name=datasets.Split.VALIDATION,
|
| 93 |
-
gen_kwargs = {
|
| 94 |
-
"filepath": f"{valid_dir}/dev.{src_tag}",
|
| 95 |
-
"labelpath": f"{valid_dir}/dev.{tgt_tag}",
|
| 96 |
-
"files": dl_manager.iter_archive(archive)
|
| 97 |
-
}
|
| 98 |
-
)
|
| 99 |
-
|
| 100 |
-
test = datasets.SplitGenerator(
|
| 101 |
-
name=datasets.Split.TEST,
|
| 102 |
-
gen_kwargs = {
|
| 103 |
-
"filepath": f"{test_dir}/test.{src_tag}",
|
| 104 |
-
"labelpath": f"{test_dir}/test.{tgt_tag}",
|
| 105 |
-
"files": dl_manager.iter_archive(archive)
|
| 106 |
-
}
|
| 107 |
-
)
|
| 108 |
-
|
| 109 |
-
output = []
|
| 110 |
-
|
| 111 |
-
output.append(train)
|
| 112 |
-
output.append(valid)
|
| 113 |
-
output.append(test)
|
| 114 |
-
|
| 115 |
-
return output
|
| 116 |
-
|
| 117 |
-
def _generate_examples(self, filepath, labelpath, files):
|
| 118 |
-
""" Yield examples """
|
| 119 |
-
src_tag, tgt_tag = self.config.language_pair.split("-")
|
| 120 |
-
src, tgt = None, None
|
| 121 |
-
|
| 122 |
-
for path, f in files:
|
| 123 |
-
if(path == filepath):
|
| 124 |
-
src = f.read().decode("utf-8").split("\n")[:-1]
|
| 125 |
-
elif(path == labelpath):
|
| 126 |
-
tgt = f.read().decode("utf-8").split("\n")[:-1]
|
| 127 |
-
|
| 128 |
-
if(src is not None and tgt is not None):
|
| 129 |
-
for idx, (s,t) in enumerate(zip(src, tgt)):
|
| 130 |
-
yield idx, {"translation": {src_tag: s, tgt_tag: t}}
|
| 131 |
-
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|