Davlan commited on
Commit
1c716b0
1 Parent(s): e50c3ac

Upload 2 files

Browse files

adding masakhanews

Files changed (2) hide show
  1. README.md +246 -1
  2. masakhanews.py +152 -0
README.md CHANGED
@@ -1,3 +1,248 @@
1
  ---
2
- license: afl-3.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language:
5
+ - am
6
+ - en
7
+ - fr
8
+ - ha
9
+ - ig
10
+ - ln
11
+ - lg
12
+ - om
13
+ - pcm
14
+ - rn
15
+ - sn
16
+ - so
17
+ - sw
18
+ - ti
19
+ - xh
20
+ - yo
21
+ language_creators:
22
+ - expert-generated
23
+ license:
24
+ - afl-3.0
25
+ multilinguality:
26
+ - multilingual
27
+ pretty_name: masakhanews
28
+ size_categories:
29
+ - 1K<n<10K
30
+ source_datasets:
31
+ - original
32
+ tags:
33
+ - news-topic
34
+ - masakhanews
35
+ - masakhane
36
+ task_categories:
37
+ - text-classification
38
+ task_ids:
39
+ - topic-classification
40
+
41
  ---
42
+
43
+
44
+ # Dataset Card for [Dataset Name]
45
+
46
+ ## Table of Contents
47
+ - [Table of Contents](#table-of-contents)
48
+ - [Dataset Description](#dataset-description)
49
+ - [Dataset Summary](#dataset-summary)
50
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
51
+ - [Languages](#languages)
52
+ - [Dataset Structure](#dataset-structure)
53
+ - [Data Instances](#data-instances)
54
+ - [Data Fields](#data-fields)
55
+ - [Data Splits](#data-splits)
56
+ - [Dataset Creation](#dataset-creation)
57
+ - [Curation Rationale](#curation-rationale)
58
+ - [Source Data](#source-data)
59
+ - [Annotations](#annotations)
60
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
61
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
62
+ - [Social Impact of Dataset](#social-impact-of-dataset)
63
+ - [Discussion of Biases](#discussion-of-biases)
64
+ - [Other Known Limitations](#other-known-limitations)
65
+ - [Additional Information](#additional-information)
66
+ - [Dataset Curators](#dataset-curators)
67
+ - [Licensing Information](#licensing-information)
68
+ - [Citation Information](#citation-information)
69
+ - [Contributions](#contributions)
70
+
71
+ ## Dataset Description
72
+
73
+ - **Homepage:** [homepage](https://github.com/masakhane-io/masakhane-news)
74
+ - **Repository:** [github](https://github.com/masakhane-io/masakhane-news)
75
+ - **Paper:** [paper]()
76
+ - **Point of Contact:** [Masakhane](https://www.masakhane.io/) or [email protected]
77
+
78
+ ### Dataset Summary
79
+
80
+ MasakhaNEWS is the largest publicly available dataset for news topic classification in 16 languages widely spoken in Africa.
81
+
82
+
83
+ The train/validation/test sets are available for all the 16 languages.
84
+
85
+
86
+
87
+ ### Supported Tasks and Leaderboards
88
+
89
+ [More Information Needed]
90
+
91
+ - `named-entity-recognition`: The performance in this task is measured with [F1](https://huggingface.co/metrics/f1) (higher is better). A named entity is correct only if it is an exact match of the corresponding entity in the data.
92
+
93
+ ### Languages
94
+
95
+ There are 16 languages available :
96
+ - Amharic (amh)
97
+ - English (eng)
98
+ - French (fra)
99
+ - Hausa (hau)
100
+ - Igbo (ibo)
101
+ - Lingala (lin)
102
+ - Luganda (lug)
103
+ - Oromo (orm)
104
+ - Nigerian Pidgin (pcm)
105
+ - Rundi (run)
106
+ - chShona (sna)
107
+ - Somali (som)
108
+ - Kiswahili (swą)
109
+ - Tigrinya (tir)
110
+ - isiXhosa (xho)
111
+ - Yorùbá (yor)
112
+
113
+ ## Dataset Structure
114
+
115
+ ### Data Instances
116
+
117
+ The examples look like this for Yorùbá:
118
+
119
+ ```
120
+ from datasets import load_dataset
121
+ data = load_dataset('masakhanews', 'yor')
122
+
123
+ # Please, specify the language code
124
+
125
+ # A data point example is below:
126
+
127
+ {
128
+ 'label': 0,
129
+ 'headline': "'The barriers to entry have gone - go for it now'",
130
+ 'text': "j Lalvani, CEO of Vitabiotics and former Dragons' Den star, shares his business advice for our CEO Secrets series.\nProduced, filmed and edited by Dougal Shaw",
131
+ 'headline_text': "'The barriers to entry have gone - go for it now' j Lalvani, CEO of Vitabiotics and former Dragons' Den star, shares his business advice for our CEO Secrets series.\nProduced, filmed and edited by Dougal Shaw",
132
+ 'url': '/news/business-61880859'
133
+ }
134
+ ```
135
+
136
+ ### Data Fields
137
+
138
+ - `label`: news topic id
139
+ - `headline`: news title/headline
140
+ - `text`: news body
141
+ - `headline_text`: concatenation of headline and news body
142
+ - `url`: website address
143
+
144
+ The news topics correspond to this list:
145
+ ```
146
+ "business", "entertainment", "health", "politics", "religion", "sports", "technology"
147
+ ```
148
+
149
+ ### Data Splits
150
+
151
+ For all languages, there are three splits.
152
+
153
+ The original splits were named `train`, `dev` and `test` and they correspond to the `train`, `validation` and `test` splits.
154
+
155
+ The splits have the following sizes :
156
+
157
+ | Language | train | validation | test |
158
+ |-----------------|------:|-----------:|-----:|
159
+ | Amharic | 1311 | 188 | 376 |
160
+ | English | 3309 | 472 | 948 |
161
+ | French | 1476 | 211 | 422 |
162
+ | Hausa | 2219 | 317 | 637 |
163
+ | Igbo | 1356 | 194 | 390 |
164
+ | Lingala | 608 | 87 | 175 |
165
+ | Luganda | 771 | 110 | 223 |
166
+ | Oromo | 1015 | 145 | 292 |
167
+ | Nigerian-Pidgin | 1060 | 152 | 305 |
168
+ | Rundi | 1117 | 159 | 322 |
169
+ | chiShona | 1288 | 185 | 369 |
170
+ | Somali | 1021 | 148 | 294 |
171
+ | Kiswahili | 1658 | 237 | 476 |
172
+ | Tigrinya | 947 | 137 | 272 |
173
+ | isiXhosa | 1032 | 147 | 297 |
174
+ | Yoruba | 1433 | 206 | 411 |
175
+
176
+ ## Dataset Creation
177
+
178
+ ### Curation Rationale
179
+
180
+ The dataset was introduced to introduce new resources to 20 languages that were under-served for natural language processing.
181
+
182
+ [More Information Needed]
183
+
184
+ ### Source Data
185
+
186
+ The source of the data is from the news domain, details can be found here ****
187
+
188
+ #### Initial Data Collection and Normalization
189
+
190
+ The articles were word-tokenized, information on the exact pre-processing pipeline is unavailable.
191
+
192
+ #### Who are the source language producers?
193
+
194
+ The source language was produced by journalists and writers employed by the news agency and newspaper mentioned above.
195
+
196
+ ### Annotations
197
+
198
+ #### Annotation process
199
+
200
+ Details can be found here **
201
+
202
+ #### Who are the annotators?
203
+
204
+ Annotators were recruited from [Masakhane](https://www.masakhane.io/)
205
+
206
+ ### Personal and Sensitive Information
207
+
208
+ The data is sourced from newspaper source and only contains mentions of public figures or individuals
209
+
210
+ ## Considerations for Using the Data
211
+
212
+ ### Social Impact of Dataset
213
+ [More Information Needed]
214
+
215
+
216
+ ### Discussion of Biases
217
+ [More Information Needed]
218
+
219
+
220
+ ### Other Known Limitations
221
+
222
+ Users should keep in mind that the dataset only contains news text, which might limit the applicability of the developed systems to other domains.
223
+
224
+ ## Additional Information
225
+
226
+ ### Dataset Curators
227
+
228
+
229
+ ### Licensing Information
230
+
231
+ The licensing status of the data is CC 4.0 Non-Commercial
232
+
233
+ ### Citation Information
234
+
235
+ Provide the [BibTex](http://www.bibtex.org/)-formatted reference for the dataset. For example:
236
+ ```
237
+ @article{Adelani2023MasakhaNEWS,
238
+ title={MasakhaNEWS: News Topic Classification for African languages},
239
+ author={David Ifeoluwa Adelani and Marek Masiak and Israel Abebe Azime and Jesujoba Oluwadara Alabi and Atnafu Lambebo Tonja and Christine Mwase and Odunayo Ogundepo and Bonaventure F. P. Dossou and Akintunde Oladipo and Doreen Nixdorf and Chris Chinenye Emezue and Sana Sabah al-azzawi and Blessing K. Sibanda and Davis David and Lolwethu Ndolela and Jonathan Mukiibi and Tunde Oluwaseyi Ajayi and Tatiana Moteu Ngoli and Brian Odhiambo and Abraham Toluwase Owodunni and Nnaemeka C. Obiefuna and Shamsuddeen Hassan Muhammad and Saheed Salahudeen Abdullahi and Mesay Gemeda Yigezu and Tajuddeen Gwadabe and Idris Abdulmumin and Mahlet Taye Bame and Oluwabusayo Olufunke Awoyomi and Iyanuoluwa Shode and Tolulope Anu Adelani and Habiba Abdulganiy Kailani and Abdul-Hakeem Omotayo and Adetola Adeeko and Afolabi Abeeb and Anuoluwapo Aremu and Olanrewaju Samuel and Clemencia Siro and Wangari Kimotho and Onyekachi Raphael Ogbu and Chinedu E. Mbonu and Chiamaka I. Chukwuneke and Samuel Fanijo and Jessica Ojo and Oyinkansola F. Awosan and Tadesse Kebede Guge and Sakayo Toadoum Sari and Pamela Nyatsine and Freedmore Sidume and Oreen Yousuf and Mardiyyah Oduwole and Ussen Kimanuka and Kanda Patrick Tshinu and Thina Diko and Siyanda Nxakama and Abdulmejid Tuni Johar and Sinodos Gebre and Muhidin Mohamed and Shafie Abdi Mohamed and Fuad Mire Hassan and Moges Ahmed Mehamed and Evrard Ngabire and and Pontus Stenetorp},
240
+ journal={ArXiv},
241
+ year={2023},
242
+ volume={}
243
+ }
244
+ ```
245
+
246
+ ### Contributions
247
+
248
+ Thanks to [@dadelani](https://github.com/dadelani) for adding this dataset.
masakhanews.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """MasakhaNEWS: News Topic Classification for African languages"""
18
+
19
+ import datasets
20
+ import pandas
21
+ import pandas as pd
22
+
23
+ logger = datasets.logging.get_logger(__name__)
24
+
25
+
26
+ _CITATION = """\
27
+ @article{Adelani2023MasakhaNEWS,
28
+ title={MasakhaNEWS: News Topic Classification for African languages},
29
+ author={David Ifeoluwa Adelani and Marek Masiak and Israel Abebe Azime and Jesujoba Oluwadara Alabi and Atnafu Lambebo Tonja and Christine Mwase and Odunayo Ogundepo and Bonaventure F. P. Dossou and Akintunde Oladipo and Doreen Nixdorf and Chris Chinenye Emezue and Sana Sabah al-azzawi and Blessing K. Sibanda and Davis David and Lolwethu Ndolela and Jonathan Mukiibi and Tunde Oluwaseyi Ajayi and Tatiana Moteu Ngoli and Brian Odhiambo and Abraham Toluwase Owodunni and Nnaemeka C. Obiefuna and Shamsuddeen Hassan Muhammad and Saheed Salahudeen Abdullahi and Mesay Gemeda Yigezu and Tajuddeen Gwadabe and Idris Abdulmumin and Mahlet Taye Bame and Oluwabusayo Olufunke Awoyomi and Iyanuoluwa Shode and Tolulope Anu Adelani and Habiba Abdulganiy Kailani and Abdul-Hakeem Omotayo and Adetola Adeeko and Afolabi Abeeb and Anuoluwapo Aremu and Olanrewaju Samuel and Clemencia Siro and Wangari Kimotho and Onyekachi Raphael Ogbu and Chinedu E. Mbonu and Chiamaka I. Chukwuneke and Samuel Fanijo and Jessica Ojo and Oyinkansola F. Awosan and Tadesse Kebede Guge and Sakayo Toadoum Sari and Pamela Nyatsine and Freedmore Sidume and Oreen Yousuf and Mardiyyah Oduwole and Ussen Kimanuka and Kanda Patrick Tshinu and Thina Diko and Siyanda Nxakama and Abdulmejid Tuni Johar and Sinodos Gebre and Muhidin Mohamed and Shafie Abdi Mohamed and Fuad Mire Hassan and Moges Ahmed Mehamed and Evrard Ngabire and and Pontus Stenetorp},
30
+ journal={ArXiv},
31
+ year={2023},
32
+ volume={}
33
+ }
34
+ """
35
+
36
+ _DESCRIPTION = """\
37
+ MasakhaNEWS is the largest publicly available dataset for news topic classification in 16 languages widely spoken in Africa.
38
+
39
+ The languages are:
40
+ - Amharic (amh)
41
+ - English (eng)
42
+ - French (fra)
43
+ - Hausa (hau)
44
+ - Igbo (ibo)
45
+ - Lingala (lin)
46
+ - Luganda (lug)
47
+ - Oromo (orm)
48
+ - Nigerian Pidgin (pcm)
49
+ - Rundi (run)
50
+ - chShona (sna)
51
+ - Somali (som)
52
+ - Kiswahili (swą)
53
+ - Tigrinya (tir)
54
+ - isiXhosa (xho)
55
+ - Yorùbá (yor)
56
+
57
+ The train/validation/test sets are available for all the 16 languages.
58
+
59
+ For more details see *** arXiv link **
60
+ """
61
+ _URL = "https://github.com/masakhane-io/masakhane-news/raw/main/data/"
62
+ _TRAINING_FILE = "train.tsv"
63
+ _DEV_FILE = "dev.tsv"
64
+ _TEST_FILE = "test.tsv"
65
+
66
+
67
+ class MasakhanewsConfig(datasets.BuilderConfig):
68
+ """BuilderConfig for Masakhanews"""
69
+
70
+ def __init__(self, **kwargs):
71
+ """BuilderConfig for Masakhanews.
72
+
73
+ Args:
74
+ **kwargs: keyword arguments forwarded to super.
75
+ """
76
+ super(MasakhanewsConfig, self).__init__(**kwargs)
77
+
78
+
79
+ class Masakhanews(datasets.GeneratorBasedBuilder):
80
+ """Masakhanews dataset."""
81
+
82
+ BUILDER_CONFIGS = [
83
+ MasakhanewsConfig(name="amh", version=datasets.Version("1.0.0"), description="Masakhanews Amharic dataset"),
84
+ MasakhanewsConfig(name="eng", version=datasets.Version("1.0.0"), description="Masakhanews English dataset"),
85
+ MasakhanewsConfig(name="fra", version=datasets.Version("1.0.0"), description="Masakhanews French dataset"),
86
+ MasakhanewsConfig(name="hau", version=datasets.Version("1.0.0"), description="Masakhanews Hausa dataset"),
87
+ MasakhanewsConfig(name="ibo", version=datasets.Version("1.0.0"), description="Masakhanews Igbo dataset"),
88
+ MasakhanewsConfig(name="lin", version=datasets.Version("1.0.0"), description="Masakhanews Lingala dataset"),
89
+ MasakhanewsConfig(name="lug", version=datasets.Version("1.0.0"), description="Masakhanews Luganda dataset"),
90
+ MasakhanewsConfig(name="orm", version=datasets.Version("1.0.0"), description="Masakhanews Oromo dataset"),
91
+ MasakhanewsConfig(
92
+ name="pcm", version=datasets.Version("1.0.0"), description="Masakhanews Nigerian-Pidgin dataset"
93
+ ),
94
+ MasakhanewsConfig(name="run", version=datasets.Version("1.0.0"), description="Masakhanews Rundi dataset"),
95
+ MasakhanewsConfig(name="sna", version=datasets.Version("1.0.0"), description="Masakhanews Shona dataset"),
96
+ MasakhanewsConfig(name="som", version=datasets.Version("1.0.0"), description="Masakhanews Somali dataset"),
97
+ MasakhanewsConfig(name="swa", version=datasets.Version("1.0.0"), description="Masakhanews Swahili dataset"),
98
+ MasakhanewsConfig(name="tir", version=datasets.Version("1.0.0"), description="Masakhanews Tigrinya dataset"),
99
+ MasakhanewsConfig(name="xho", version=datasets.Version("1.0.0"), description="Masakhanews Xhosa dataset"),
100
+ MasakhanewsConfig(name="yor", version=datasets.Version("1.0.0"), description="Masakhanews Yoruba dataset"),
101
+ ]
102
+
103
+ def _info(self):
104
+ return datasets.DatasetInfo(
105
+ description=_DESCRIPTION,
106
+ features=datasets.Features(
107
+ {
108
+ "label": datasets.features.ClassLabel(
109
+ names=["business", "entertainment", "health", "politics", "religion", "sports", "technology"]
110
+ ),
111
+ "headline": datasets.Value("string"),
112
+ "text": datasets.Value("string"),
113
+ "headline_text": datasets.Value("string"),
114
+ "url": datasets.Value("string"),
115
+ }
116
+ ),
117
+ supervised_keys=None,
118
+ homepage="https://github.com/masakhane-io/masakhane-news",
119
+ citation=_CITATION,
120
+ )
121
+
122
+ def _split_generators(self, dl_manager):
123
+ """Returns SplitGenerators."""
124
+ urls_to_download = {
125
+ "train": f"{_URL}{self.config.name}/{_TRAINING_FILE}",
126
+ "dev": f"{_URL}{self.config.name}/{_DEV_FILE}",
127
+ "test": f"{_URL}{self.config.name}/{_TEST_FILE}",
128
+ }
129
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
130
+
131
+ return [
132
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
133
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
134
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
135
+ ]
136
+
137
+ def _generate_examples(self, filepath):
138
+ logger.info("⏳ Generating examples from = %s", filepath)
139
+ df = pd.read_csv(filepath, sep='\t')
140
+ N = df.shape[0]
141
+
142
+ for id_ in range(N):
143
+ yield id_, {
144
+ "label": df['category'].iloc[id_],
145
+ "headline": df['headline'].iloc[id_],
146
+ "text": df['text'].iloc[id_],
147
+ "headline_text": df['headline'].iloc[id_] + ' ' + df['text'].iloc[id_],
148
+ "url": df['url'].iloc[id_],
149
+ }
150
+
151
+
152
+