fgaim commited on
Commit
3a034e7
1 Parent(s): 20496a6

Loader script

Browse files
Files changed (1) hide show
  1. swahili-safi.py +71 -0
swahili-safi.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Cleaned dataset for Swahili Language Modeling"""
2
+
3
+
4
+ import datasets
5
+
6
+
7
+ _CITATION = """\
8
+ @InProceedings{huggingface:flax-community,
9
+ title = Cleaned dataset for Swahili Language Modeling,
10
+ authors={Fitsum, Alok, Patrick},
11
+ year={2021},
12
+ link = https://huggingface.co/datasets/flax-community/swahili-safi
13
+ }
14
+ """
15
+
16
+ _DESCRIPTION = """Cleaned dataset for Swahili Language Modeling"""
17
+ _HOMEPAGE = "https://huggingface.co/datasets/flax-community/swahili-safi"
18
+ _LICENSE = "Attribution 4.0 International"
19
+ _REPO_URL = "https://huggingface.co/datasets/flax-community/swahili-safi/resolve/main/"
20
+ _TRAIN= [_REPO_URL + file_name for file_name in [
21
+ "data/train.txt",
22
+ ]]
23
+
24
+
25
+ class SwahiliSafi(datasets.GeneratorBasedBuilder):
26
+ """The Swahili dataset for language modeling"""
27
+
28
+ VERSION = datasets.Version("1.0.0")
29
+ BUILDER_CONFIGS = [
30
+ datasets.BuilderConfig(
31
+ name="swahili-safi",
32
+ version=VERSION,
33
+ description="Language modeling dataset for Swahili"
34
+ ),
35
+ ]
36
+
37
+ def _info(self):
38
+ return datasets.DatasetInfo(
39
+ description=_DESCRIPTION,
40
+ features=datasets.Features(
41
+ {
42
+ "text": datasets.Value("string"),
43
+ }
44
+ ),
45
+ supervised_keys=None,
46
+ homepage=_HOMEPAGE,
47
+ license=_LICENSE,
48
+ citation=_CITATION,
49
+ )
50
+
51
+ def _split_generators(self, dl_manager):
52
+ """Returns SplitGenerators."""
53
+ train_files = dl_manager.download(_TRAIN)
54
+ return [
55
+ datasets.SplitGenerator(
56
+ name=datasets.Split.TRAIN,
57
+ gen_kwargs={
58
+ "data_files": train_files,
59
+ "split": "train",
60
+ },
61
+ )
62
+ ]
63
+
64
+ def _generate_examples(self, data_files):
65
+ """Yields examples."""
66
+ _id = 0
67
+ for filepath in data_files:
68
+ with open(filepath, mode="r", encoding="utf-8") as f:
69
+ for line in f:
70
+ yield _id, {"text": line.strip()},
71
+ _id += 1