nehahumbe Davlan commited on
Commit
b97e2f9
·
0 Parent(s):

Duplicate from masakhane/mafand

Browse files

Co-authored-by: David Adelani <Davlan@users.noreply.huggingface.co>

Files changed (3) hide show
  1. .gitattributes +51 -0
  2. README.md +278 -0
  3. mafand.py +226 -0
.gitattributes ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ftz filter=lfs diff=lfs merge=lfs -text
6
+ *.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.h5 filter=lfs diff=lfs merge=lfs -text
8
+ *.joblib filter=lfs diff=lfs merge=lfs -text
9
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
10
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.npy filter=lfs diff=lfs merge=lfs -text
14
+ *.npz filter=lfs diff=lfs merge=lfs -text
15
+ *.onnx filter=lfs diff=lfs merge=lfs -text
16
+ *.ot filter=lfs diff=lfs merge=lfs -text
17
+ *.parquet filter=lfs diff=lfs merge=lfs -text
18
+ *.pb filter=lfs diff=lfs merge=lfs -text
19
+ *.pickle filter=lfs diff=lfs merge=lfs -text
20
+ *.pkl filter=lfs diff=lfs merge=lfs -text
21
+ *.pt filter=lfs diff=lfs merge=lfs -text
22
+ *.pth filter=lfs diff=lfs merge=lfs -text
23
+ *.rar filter=lfs diff=lfs merge=lfs -text
24
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
25
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
26
+ *.tflite filter=lfs diff=lfs merge=lfs -text
27
+ *.tgz filter=lfs diff=lfs merge=lfs -text
28
+ *.wasm filter=lfs diff=lfs merge=lfs -text
29
+ *.xz filter=lfs diff=lfs merge=lfs -text
30
+ *.zip filter=lfs diff=lfs merge=lfs -text
31
+ *.zst filter=lfs diff=lfs merge=lfs -text
32
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
33
+ # Audio files - uncompressed
34
+ *.pcm filter=lfs diff=lfs merge=lfs -text
35
+ *.sam filter=lfs diff=lfs merge=lfs -text
36
+ *.raw filter=lfs diff=lfs merge=lfs -text
37
+ # Audio files - compressed
38
+ *.aac filter=lfs diff=lfs merge=lfs -text
39
+ *.flac filter=lfs diff=lfs merge=lfs -text
40
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
41
+ *.ogg filter=lfs diff=lfs merge=lfs -text
42
+ *.wav filter=lfs diff=lfs merge=lfs -text
43
+ # Image files - uncompressed
44
+ *.bmp filter=lfs diff=lfs merge=lfs -text
45
+ *.gif filter=lfs diff=lfs merge=lfs -text
46
+ *.png filter=lfs diff=lfs merge=lfs -text
47
+ *.tiff filter=lfs diff=lfs merge=lfs -text
48
+ # Image files - compressed
49
+ *.jpg filter=lfs diff=lfs merge=lfs -text
50
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
51
+ *.webp filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language:
5
+ - en
6
+ - fr
7
+ - am
8
+ - bm
9
+ - bbj
10
+ - ee
11
+ - fon
12
+ - ha
13
+ - ig
14
+ - lg
15
+ - mos
16
+ - ny
17
+ - pcm
18
+ - rw
19
+ - sn
20
+ - sw
21
+ - tn
22
+ - tw
23
+ - wo
24
+ - xh
25
+ - yo
26
+ - zu
27
+ language_creators:
28
+ - expert-generated
29
+ license:
30
+ - cc-by-nc-4.0
31
+ multilinguality:
32
+ - translation
33
+ - multilingual
34
+ pretty_name: mafand
35
+ size_categories:
36
+ - 1K<n<10K
37
+ source_datasets:
38
+ - original
39
+ tags:
40
+ - news, mafand, masakhane
41
+ task_categories:
42
+ - translation
43
+ task_ids: []
44
+ ---
45
+
46
+ # Dataset Card for MAFAND
47
+
48
+ ## Table of Contents
49
+ - [Dataset Description](#dataset-description)
50
+ - [Dataset Summary](#dataset-summary)
51
+ - [Supported Tasks](#supported-tasks-and-leaderboards)
52
+ - [Languages](#languages)
53
+ - [Dataset Structure](#dataset-structure)
54
+ - [Data Instances](#data-instances)
55
+ - [Data Fields](#data-instances)
56
+ - [Data Splits](#data-instances)
57
+ - [Dataset Creation](#dataset-creation)
58
+ - [Curation Rationale](#curation-rationale)
59
+ - [Source Data](#source-data)
60
+ - [Annotations](#annotations)
61
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
62
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
63
+ - [Social Impact of Dataset](#social-impact-of-dataset)
64
+ - [Discussion of Biases](#discussion-of-biases)
65
+ - [Other Known Limitations](#other-known-limitations)
66
+ - [Additional Information](#additional-information)
67
+ - [Dataset Curators](#dataset-curators)
68
+ - [Licensing Information](#licensing-information)
69
+ - [Citation Information](#citation-information)
70
+
71
+ ## Dataset Description
72
+
73
+ - **Homepage:** https://github.com/masakhane-io/lafand-mt
74
+ - **Repository:** https://github.com/masakhane-io/lafand-mt
75
+ - **Paper:** https://aclanthology.org/2022.naacl-main.223/
76
+ - **Leaderboard:** [Needs More Information]
77
+ - **Point of Contact:** [David Adelani](https://dadelani.github.io/)
78
+
79
+ ### Dataset Summary
80
+
81
+ MAFAND-MT is the largest MT benchmark for African languages in the news domain, covering 21 languages.
82
+
83
+ ### Supported Tasks and Leaderboards
84
+
85
+ Machine Translation
86
+
87
+ ### Languages
88
+
89
+ The languages covered are:
90
+ - Amharic
91
+ - Bambara
92
+ - Ghomala
93
+ - Ewe
94
+ - Fon
95
+ - Hausa
96
+ - Igbo
97
+ - Kinyarwanda
98
+ - Luganda
99
+ - Luo
100
+ - Mossi
101
+ - Nigerian-Pidgin
102
+ - Chichewa
103
+ - Shona
104
+ - Swahili
105
+ - Setswana
106
+ - Twi
107
+ - Wolof
108
+ - Xhosa
109
+ - Yoruba
110
+ - Zulu
111
+
112
+ ## Dataset Structure
113
+
114
+ ### Data Instances
115
+ ```
116
+ >>> from datasets import load_dataset
117
+ >>> data = load_dataset('masakhane/mafand', 'en-yor')
118
+
119
+ {"translation": {"src": "President Buhari will determine when to lift lockdown – Minister", "tgt": "Ààrẹ Buhari ló lè yóhùn padà lórí ètò kónílégbélé – Mínísítà"}}
120
+
121
+
122
+ {"translation": {"en": "President Buhari will determine when to lift lockdown – Minister", "yo": "Ààrẹ Buhari ló lè yóhùn padà lórí ètò kónílégbélé – Mínísítà"}}
123
+ ```
124
+
125
+ ### Data Fields
126
+
127
+ - "translation": name of the task
128
+ - "src" : source language e.g en
129
+ - "tgt": target language e.g yo
130
+
131
+ ### Data Splits
132
+
133
+ Train/dev/test split
134
+
135
+ language| Train| Dev |Test
136
+ -|-|-|-
137
+ amh |-|899|1037
138
+ bam |3302|1484|1600
139
+ bbj |2232|1133|1430
140
+ ewe |2026|1414|1563
141
+ fon |2637|1227|1579
142
+ hau |5865|1300|1500
143
+ ibo |6998|1500|1500
144
+ kin |-|460|1006
145
+ lug |4075|1500|1500
146
+ luo |4262|1500|1500
147
+ mos |2287|1478|1574
148
+ nya |-|483|1004
149
+ pcm |4790|1484|1574
150
+ sna |-|556|1005
151
+ swa |30782|1791|1835
152
+ tsn |2100|1340|1835
153
+ twi |3337|1284|1500
154
+ wol |3360|1506|1500|
155
+ xho |-|486|1002|
156
+ yor |6644|1544|1558|
157
+ zul |3500|1239|998|
158
+
159
+
160
+ ## Dataset Creation
161
+
162
+ ### Curation Rationale
163
+
164
+ MAFAND was created from the news domain, translated from English or French to an African language
165
+
166
+ ### Source Data
167
+
168
+ #### Initial Data Collection and Normalization
169
+
170
+ [Needs More Information]
171
+
172
+ #### Who are the source language producers?
173
+
174
+ - [Masakhane](https://github.com/masakhane-io/lafand-mt)
175
+ - [Igbo](https://github.com/IgnatiusEzeani/IGBONLP/tree/master/ig_en_mt)
176
+ - [Swahili](https://opus.nlpl.eu/GlobalVoices.php)
177
+ - [Hausa](https://www.statmt.org/wmt21/translation-task.html)
178
+ - [Yoruba](https://github.com/uds-lsv/menyo-20k_MT)
179
+
180
+ ### Annotations
181
+
182
+ #### Annotation process
183
+
184
+ [Needs More Information]
185
+
186
+ #### Who are the annotators?
187
+
188
+ Masakhane members
189
+
190
+ ### Personal and Sensitive Information
191
+
192
+ [Needs More Information]
193
+
194
+ ## Considerations for Using the Data
195
+
196
+ ### Social Impact of Dataset
197
+
198
+ [Needs More Information]
199
+
200
+ ### Discussion of Biases
201
+
202
+ [Needs More Information]
203
+
204
+ ### Other Known Limitations
205
+
206
+ [Needs More Information]
207
+
208
+ ## Additional Information
209
+
210
+ ### Dataset Curators
211
+
212
+ [Needs More Information]
213
+
214
+ ### Licensing Information
215
+
216
+ [CC-BY-4.0-NC](https://creativecommons.org/licenses/by-nc/4.0/)
217
+
218
+ ### Citation Information
219
+
220
+ ```
221
+ @inproceedings{adelani-etal-2022-thousand,
222
+ title = "A Few Thousand Translations Go a Long Way! Leveraging Pre-trained Models for {A}frican News Translation",
223
+ author = "Adelani, David and
224
+ Alabi, Jesujoba and
225
+ Fan, Angela and
226
+ Kreutzer, Julia and
227
+ Shen, Xiaoyu and
228
+ Reid, Machel and
229
+ Ruiter, Dana and
230
+ Klakow, Dietrich and
231
+ Nabende, Peter and
232
+ Chang, Ernie and
233
+ Gwadabe, Tajuddeen and
234
+ Sackey, Freshia and
235
+ Dossou, Bonaventure F. P. and
236
+ Emezue, Chris and
237
+ Leong, Colin and
238
+ Beukman, Michael and
239
+ Muhammad, Shamsuddeen and
240
+ Jarso, Guyo and
241
+ Yousuf, Oreen and
242
+ Niyongabo Rubungo, Andre and
243
+ Hacheme, Gilles and
244
+ Wairagala, Eric Peter and
245
+ Nasir, Muhammad Umair and
246
+ Ajibade, Benjamin and
247
+ Ajayi, Tunde and
248
+ Gitau, Yvonne and
249
+ Abbott, Jade and
250
+ Ahmed, Mohamed and
251
+ Ochieng, Millicent and
252
+ Aremu, Anuoluwapo and
253
+ Ogayo, Perez and
254
+ Mukiibi, Jonathan and
255
+ Ouoba Kabore, Fatoumata and
256
+ Kalipe, Godson and
257
+ Mbaye, Derguene and
258
+ Tapo, Allahsera Auguste and
259
+ Memdjokam Koagne, Victoire and
260
+ Munkoh-Buabeng, Edwin and
261
+ Wagner, Valencia and
262
+ Abdulmumin, Idris and
263
+ Awokoya, Ayodele and
264
+ Buzaaba, Happy and
265
+ Sibanda, Blessing and
266
+ Bukula, Andiswa and
267
+ Manthalu, Sam",
268
+ booktitle = "Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
269
+ month = jul,
270
+ year = "2022",
271
+ address = "Seattle, United States",
272
+ publisher = "Association for Computational Linguistics",
273
+ url = "https://aclanthology.org/2022.naacl-main.223",
274
+ doi = "10.18653/v1/2022.naacl-main.223",
275
+ pages = "3053--3070",
276
+ abstract = "Recent advances in the pre-training for language models leverage large-scale datasets to create multilingual models. However, low-resource languages are mostly left out in these datasets. This is primarily because many widely spoken languages that are not well represented on the web and therefore excluded from the large-scale crawls for datasets. Furthermore, downstream users of these models are restricted to the selection of languages originally chosen for pre-training. This work investigates how to optimally leverage existing pre-trained models to create low-resource translation systems for 16 African languages. We focus on two questions: 1) How can pre-trained models be used for languages not included in the initial pretraining? and 2) How can the resulting translation models effectively transfer to new domains? To answer these questions, we create a novel African news corpus covering 16 languages, of which eight languages are not part of any existing evaluation dataset. We demonstrate that the most effective strategy for transferring both additional languages and additional domains is to leverage small quantities of high-quality translation data to fine-tune large pre-trained models.",
277
+ }
278
+ ```
mafand.py ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 HuggingFace Datasets Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """MAFAND-MT: Masakhane Anglo and Franco Africa News Dataset for Machine Translation"""
18
+
19
+ import datasets
20
+ import json
21
+
22
+ logger = datasets.logging.get_logger(__name__)
23
+
24
+ _CITATION = """\
25
+ @inproceedings{adelani-etal-2022-thousand,
26
+ title = "A Few Thousand Translations Go a Long Way! Leveraging Pre-trained Models for {A}frican News Translation",
27
+ author = "Adelani, David and
28
+ Alabi, Jesujoba and
29
+ Fan, Angela and
30
+ Kreutzer, Julia and
31
+ Shen, Xiaoyu and
32
+ Reid, Machel and
33
+ Ruiter, Dana and
34
+ Klakow, Dietrich and
35
+ Nabende, Peter and
36
+ Chang, Ernie and
37
+ Gwadabe, Tajuddeen and
38
+ Sackey, Freshia and
39
+ Dossou, Bonaventure F. P. and
40
+ Emezue, Chris and
41
+ Leong, Colin and
42
+ Beukman, Michael and
43
+ Muhammad, Shamsuddeen and
44
+ Jarso, Guyo and
45
+ Yousuf, Oreen and
46
+ Niyongabo Rubungo, Andre and
47
+ Hacheme, Gilles and
48
+ Wairagala, Eric Peter and
49
+ Nasir, Muhammad Umair and
50
+ Ajibade, Benjamin and
51
+ Ajayi, Tunde and
52
+ Gitau, Yvonne and
53
+ Abbott, Jade and
54
+ Ahmed, Mohamed and
55
+ Ochieng, Millicent and
56
+ Aremu, Anuoluwapo and
57
+ Ogayo, Perez and
58
+ Mukiibi, Jonathan and
59
+ Ouoba Kabore, Fatoumata and
60
+ Kalipe, Godson and
61
+ Mbaye, Derguene and
62
+ Tapo, Allahsera Auguste and
63
+ Memdjokam Koagne, Victoire and
64
+ Munkoh-Buabeng, Edwin and
65
+ Wagner, Valencia and
66
+ Abdulmumin, Idris and
67
+ Awokoya, Ayodele and
68
+ Buzaaba, Happy and
69
+ Sibanda, Blessing and
70
+ Bukula, Andiswa and
71
+ Manthalu, Sam",
72
+ booktitle = "Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
73
+ month = jul,
74
+ year = "2022",
75
+ address = "Seattle, United States",
76
+ publisher = "Association for Computational Linguistics",
77
+ url = "https://aclanthology.org/2022.naacl-main.223",
78
+ doi = "10.18653/v1/2022.naacl-main.223",
79
+ pages = "3053--3070",
80
+ abstract = "Recent advances in the pre-training for language models leverage large-scale datasets to create multilingual models. However, low-resource languages are mostly left out in these datasets. This is primarily because many widely spoken languages that are not well represented on the web and therefore excluded from the large-scale crawls for datasets. Furthermore, downstream users of these models are restricted to the selection of languages originally chosen for pre-training. This work investigates how to optimally leverage existing pre-trained models to create low-resource translation systems for 16 African languages. We focus on two questions: 1) How can pre-trained models be used for languages not included in the initial pretraining? and 2) How can the resulting translation models effectively transfer to new domains? To answer these questions, we create a novel African news corpus covering 16 languages, of which eight languages are not part of any existing evaluation dataset. We demonstrate that the most effective strategy for transferring both additional languages and additional domains is to leverage small quantities of high-quality translation data to fine-tune large pre-trained models.",
81
+ }
82
+ """
83
+
84
+ _DESCRIPTION = """\
85
+ MAFAND-MT is the largest MT benchmark for African languages in the news domain, covering 21 languages. The languages covered are:
86
+ - Amharic
87
+ - Bambara
88
+ - Ghomala
89
+ - Ewe
90
+ - Fon
91
+ - Hausa
92
+ - Igbo
93
+ - Kinyarwanda
94
+ - Luganda
95
+ - Luo
96
+ - Mossi
97
+ - Nigerian-Pidgin
98
+ - Chichewa
99
+ - Shona
100
+ - Swahili
101
+ - Setswana
102
+ - Twi
103
+ - Wolof
104
+ - Xhosa
105
+ - Yoruba
106
+ - Zulu
107
+
108
+ The train/validation/test sets are available for 16 languages, and validation/test set for amh, kin, nya, sna, and xho
109
+
110
+ For more details see https://aclanthology.org/2022.naacl-main.223/
111
+ """
112
+
113
+ _URL = "https://raw.githubusercontent.com/masakhane-io/lafand-mt/main/data/json_files/"
114
+ _TRAINING_FILE = "train.json"
115
+ _DEV_FILE = "dev.json"
116
+ _TEST_FILE = "test.json"
117
+
118
+
119
+ class MafandConfig(datasets.BuilderConfig):
120
+ """BuilderConfig for Mafand"""
121
+
122
+ def __init__(self, **kwargs):
123
+ """BuilderConfig for Masakhaner.
124
+ Args:
125
+ **kwargs: keyword arguments forwarded to super.
126
+ """
127
+ super(MafandConfig, self).__init__(**kwargs)
128
+
129
+
130
+ class Mafand(datasets.GeneratorBasedBuilder):
131
+ """Mafand dataset."""
132
+ BUILDER_CONFIGS = [
133
+ MafandConfig(name="en-amh", version=datasets.Version("1.0.0"),
134
+ description="Mafand English-Amharic dataset"),
135
+ MafandConfig(name="en-hau", version=datasets.Version("1.0.0"),
136
+ description="Mafand English-Hausa dataset"),
137
+ MafandConfig(name="en-ibo", version=datasets.Version("1.0.0"),
138
+ description="Mafand English-Igbo dataset"),
139
+ MafandConfig(name="en-kin", version=datasets.Version("1.0.0"),
140
+ description="Mafand English-Kinyarwanda dataset"),
141
+ MafandConfig(name="en-lug", version=datasets.Version("1.0.0"),
142
+ description="Mafand English-Luganda dataset"),
143
+ MafandConfig(name="en-luo", version=datasets.Version("1.0.0"),
144
+ description="Mafand English-Luo dataset"),
145
+ MafandConfig(name="en-nya", version=datasets.Version("1.0.0"),
146
+ description="Mafand English-Chichewa dataset"),
147
+ MafandConfig(name="en-pcm", version=datasets.Version("1.0.0"),
148
+ description="Mafand English-Naija dataset"),
149
+ MafandConfig(name="en-sna", version=datasets.Version("1.0.0"),
150
+ description="Mafand English-Shona dataset"),
151
+ MafandConfig(name="en-swa", version=datasets.Version("1.0.0"),
152
+ description="Mafand English-Swahili dataset"),
153
+ MafandConfig(name="en-tsn", version=datasets.Version("1.0.0"),
154
+ description="Mafand English-Setswana dataset"),
155
+ MafandConfig(name="en-twi", version=datasets.Version("1.0.0"),
156
+ description="Mafand English-Twi dataset"),
157
+ MafandConfig(name="en-xho", version=datasets.Version("1.0.0"),
158
+ description="Mafand English-Xhosa dataset"),
159
+ MafandConfig(name="en-yor", version=datasets.Version("1.0.0"),
160
+ description="Mafand English-Yoruba dataset"),
161
+ MafandConfig(name="en-zul", version=datasets.Version("1.0.0"),
162
+ description="Mafand English-Zulu dataset"),
163
+ MafandConfig(name="fr-bam", version=datasets.Version("1.0.0"),
164
+ description="Mafand French-Bambara dataset"),
165
+ MafandConfig(name="fr-bbj", version=datasets.Version("1.0.0"),
166
+ description="Mafand French-Ghomala dataset"),
167
+ MafandConfig(name="fr-ewe", version=datasets.Version("1.0.0"),
168
+ description="Mafand French-Ewe dataset"),
169
+ MafandConfig(name="fr-fon", version=datasets.Version("1.0.0"),
170
+ description="Mafand French-Fon dataset"),
171
+ MafandConfig(name="fr-mos", version=datasets.Version("1.0.0"),
172
+ description="Mafand French-Mossi dataset"),
173
+ MafandConfig(name="fr-wol", version=datasets.Version("1.0.0"),
174
+ description="Mafand French-Wolof dataset"),
175
+ ]
176
+
177
+ def _info(self):
178
+ source, target = self.config.name.split('-')
179
+ return datasets.DatasetInfo(
180
+ description=_DESCRIPTION,
181
+ features=datasets.Features({"translation": datasets.features.Translation(languages=(source, target))}),
182
+ supervised_keys=(source, target),
183
+ homepage="https://github.com/masakhane-io/lafand-mt",
184
+ citation=_CITATION,
185
+ )
186
+
187
+ def _split_generators(self, dl_manager):
188
+ """Returns SplitGenerators."""
189
+ source, target = self.config.name.split('-')
190
+ if target in ['amh', 'kin', 'nya', 'sna', 'xho']:
191
+ urls_to_download = {
192
+ "dev": f"{_URL}{self.config.name}/{_DEV_FILE}",
193
+ "test": f"{_URL}{self.config.name}/{_TEST_FILE}",
194
+ }
195
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
196
+ return [
197
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION,
198
+ gen_kwargs={"filepath": downloaded_files["dev"]}),
199
+ datasets.SplitGenerator(name=datasets.Split.TEST,
200
+ gen_kwargs={"filepath": downloaded_files["test"]}),
201
+ ]
202
+ else:
203
+ urls_to_download = {
204
+ "train": f"{_URL}{self.config.name}/{_TRAINING_FILE}",
205
+ "dev": f"{_URL}{self.config.name}/{_DEV_FILE}",
206
+ "test": f"{_URL}{self.config.name}/{_TEST_FILE}",
207
+ }
208
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
209
+
210
+ return [
211
+ datasets.SplitGenerator(name=datasets.Split.TRAIN,
212
+ gen_kwargs={"filepath": downloaded_files["train"]}),
213
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION,
214
+ gen_kwargs={"filepath": downloaded_files["dev"]}),
215
+ datasets.SplitGenerator(name=datasets.Split.TEST,
216
+ gen_kwargs={"filepath": downloaded_files["test"]}),
217
+ ]
218
+
219
+ def _generate_examples(self, filepath):
220
+ logger.info("⏳ Generating examples from = %s", filepath)
221
+ with open(filepath, encoding="utf-8") as f:
222
+ idx = 0
223
+ for line in f:
224
+ src_tgt = json.loads(line)
225
+ yield idx, src_tgt
226
+ idx += 1