abumafrim commited on
Commit
85e4222
1 Parent(s): bd06110

First commit

Browse files
Files changed (3) hide show
  1. AfriSenti-Twitter.py +152 -0
  2. README.md +243 -0
  3. dataset_infos.json +57 -0
AfriSenti-Twitter.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
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
+ """AfriSenti: A Twitter sentiment dataset for 14 African languages"""
16
+
17
+
18
+
19
+ _HOMEPAGE = "https://github.com/afrisenti-semeval/afrisent-semeval-2023"
20
+
21
+ _DESCRIPTION = """\
22
+ AfriSenti is the largest sentiment analysis benchmark dataset for under-represented African languages---covering 110,000+ annotated tweets in 14 African languages (Amharic, Algerian Arabic, Hausa, Igbo, Kinyarwanda, Moroccan Arabic, Mozambican Portuguese, Nigerian Pidgin, Oromo, Swahili, Tigrinya, Twi, Xitsonga, and yoruba).
23
+ """
24
+
25
+
26
+ _CITATION = """\
27
+ @inproceedings{muhammad-etal-2023-semeval,
28
+ title="{S}em{E}val-2023 Task 12: Sentiment Analysis for African Languages ({A}fri{S}enti-{S}em{E}val)",
29
+ author="Muhammad, Shamsuddeen Hassan and
30
+ Yimam, Seid and
31
+ Abdulmumin, Idris and
32
+ Ahmad, Ibrahim Sa'id and
33
+ Ousidhoum, Nedjma, and
34
+ Ayele, Abinew, and
35
+ Adelani, David and
36
+ Ruder, Sebastian and
37
+ Beloucif, Meriem and
38
+ Bello, Shehu Bello and
39
+ Mohammad, Saif M.",
40
+ booktitle="Proceedings of the 17th International Workshop on Semantic Evaluation (SemEval-2023)",
41
+ month=jul,
42
+ year="2023",
43
+ }
44
+ """
45
+
46
+
47
+ import csv
48
+ import textwrap
49
+ import pandas as pd
50
+
51
+ import datasets
52
+
53
+ LANGUAGES = ['amh', 'hau', 'ibo', 'arq', 'ary', 'yor', 'por', 'twi', 'tso', 'tir', 'orm', 'pcm', 'kin', 'swa']
54
+
55
+ class AfriSentiConfig(datasets.BuilderConfig):
56
+ """BuilderConfig for AfriSenti"""
57
+
58
+ def __init__(
59
+ self,
60
+ text_features,
61
+ label_column,
62
+ label_classes,
63
+ train_url,
64
+ valid_url,
65
+ test_url,
66
+ citation,
67
+ **kwargs,
68
+ ):
69
+ """BuilderConfig for AfriSenti.
70
+
71
+ Args:
72
+ text_features: `dict[string]`, map from the name of the feature
73
+ dict for each text field to the name of the column in the txt/csv/tsv file
74
+ label_column: `string`, name of the column in the txt/csv/tsv file corresponding
75
+ to the label
76
+ label_classes: `list[string]`, the list of classes if the label is categorical
77
+ train_url: `string`, url to train file from
78
+ valid_url: `string`, url to valid file from
79
+ test_url: `string`, url to test file from
80
+ citation: `string`, citation for the data set
81
+ **kwargs: keyword arguments forwarded to super.
82
+ """
83
+ super(AfriSentiConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
84
+ self.text_features = text_features
85
+ self.label_column = label_column
86
+ self.label_classes = label_classes
87
+ self.train_url = train_url
88
+ self.valid_url = valid_url
89
+ self.test_url = test_url
90
+ self.citation = citation
91
+
92
+
93
+ class AfriSenti(datasets.GeneratorBasedBuilder):
94
+ """AfriSenti benchmark"""
95
+
96
+ BUILDER_CONFIGS = []
97
+
98
+ for lang in LANGUAGES:
99
+ BUILDER_CONFIGS.append(
100
+ AfriSentiConfig(
101
+ name=lang,
102
+ description=textwrap.dedent(
103
+ f"""\
104
+ {lang} dataset."""
105
+ ),
106
+ text_features={"tweet": "tweet"},
107
+ label_classes=["positive", "neutral", "negative"],
108
+ label_column="label",
109
+ train_url=f"https://raw.githubusercontent.com/afrisenti-semeval/afrisent-semeval-2023/main/data/{lang}/train.tsv",
110
+ valid_url=f"https://raw.githubusercontent.com/afrisenti-semeval/afrisent-semeval-2023/main/data/{lang}/dev.tsv",
111
+ test_url=f"https://raw.githubusercontent.com/afrisenti-semeval/afrisent-semeval-2023/main/data/{lang}/test.tsv",
112
+ citation=textwrap.dedent(
113
+ f"""\
114
+ {lang} citation"""
115
+ ),
116
+ ),
117
+ )
118
+
119
+ def _info(self):
120
+ features = {text_feature: datasets.Value("string") for text_feature in self.config.text_features}
121
+ features["label"] = datasets.features.ClassLabel(names=self.config.label_classes)
122
+
123
+ return datasets.DatasetInfo(
124
+ description=self.config.description,
125
+ features=datasets.Features(features),
126
+ citation=self.config.citation,
127
+ )
128
+
129
+ def _split_generators(self, dl_manager):
130
+ """Returns SplitGenerators."""
131
+ train_path = dl_manager.download_and_extract(self.config.train_url)
132
+ valid_path = dl_manager.download_and_extract(self.config.valid_url)
133
+ test_path = dl_manager.download_and_extract(self.config.test_url)
134
+
135
+ return [
136
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
137
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": valid_path}),
138
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
139
+ ]
140
+
141
+ def _generate_examples(self, filepath):
142
+ df = pd.read_csv(filepath, sep='\t')
143
+
144
+ print('-'*100)
145
+ print(df.head())
146
+ print('-'*100)
147
+
148
+ for id_, row in df.iterrows():
149
+ tweet = row["tweet"]
150
+ label = row["label"]
151
+
152
+ yield id_, {"tweet": tweet, "label": label}
README.md ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ task_categories:
3
+ - text-classification
4
+ task_ids:
5
+ - sentiment-analysis
6
+ - sentiment-classification
7
+ - sentiment-scoring
8
+ - semantic-similarity-classification
9
+ - semantic-similarity-scoring
10
+ tags:
11
+ - sentiment analysis, Twitter, tweets
12
+ - sentiment
13
+ multilinguality:
14
+ - monolingual
15
+ - multilingual
16
+ size_categories:
17
+ - 100K<n<1M
18
+ language:
19
+ - amh
20
+ - ary
21
+ - ar
22
+ - arq
23
+ - hau
24
+ - ibo
25
+ - kin
26
+ - por
27
+ - pcm
28
+ - eng
29
+ - oro
30
+ - swa
31
+ - tir
32
+ - twi
33
+ - tso
34
+ - yor
35
+ pretty_name: AfriSenti
36
+ ---
37
+
38
+ # Dataset Card for AfriSenti Dataset
39
+
40
+ <p align="center">
41
+ <img src="https://raw.githubusercontent.com/afrisenti-semeval/afrisent-semeval-2023/main/images/afrisenti-twitter.png", width="700" height="500">
42
+
43
+ --------------------------------------------------------------------------------
44
+
45
+ ## Dataset Description
46
+
47
+
48
+ - **Homepage:** https://github.com/afrisenti-semeval/afrisent-semeval-2023
49
+ - **Repository:** [GitHub](https://github.com/afrisenti-semeval/afrisent-semeval-2023)
50
+ - **Paper:** [AfriSenti: AfriSenti: A Twitter Sentiment Analysis Benchmark for African Languages](https://arxiv.org/pdf/2302.08956.pdf)
51
+ - **Paper:** [NaijaSenti: A Nigerian Twitter Sentiment Corpus for Multilingual Sentiment Analysis](https://arxiv.org/pdf/2201.08277.pdf)
52
+ - **Leaderboard:** N/A
53
+ - **Point of Contact:** [shamsuddeen Muhammad](shamsuddeen2004@gmail.com)
54
+
55
+
56
+ ### Dataset Summary
57
+
58
+ AfriSenti is the largest sentiment analysis dataset for under-represented African languages, covering 110,000+ annotated tweets in 14 African languages (Amharic, Algerian Arabic, Hausa, Igbo, Kinyarwanda, Moroccan Arabic, Mozambican Portuguese, Nigerian Pidgin, Oromo, Swahili, Tigrinya, Twi, Xitsonga, and Yoruba).
59
+
60
+ The datasets are used in the first Afrocentric SemEval shared task, SemEval 2023 Task 12: Sentiment analysis for African languages (AfriSenti-SemEval). AfriSenti allows the research community to build sentiment analysis systems for various African languages and enables the study of sentiment and contemporary language use in African languages.
61
+
62
+
63
+ ### Supported Tasks and Leaderboards
64
+
65
+ The AfriSenti can be used for a wide range of sentiment analysis tasks in African languages, such as sentiment classification, sentiment intensity analysis, and emotion detection. This dataset is suitable for training and evaluating machine learning models for various NLP tasks related to sentiment analysis in African languages.
66
+ [SemEval 2023 Task 12 : Sentiment Analysis for African Languages](https://codalab.lisn.upsaclay.fr/competitions/7320)
67
+
68
+
69
+ ### Languages
70
+
71
+ 14 African languages (Amharic (amh), Algerian Arabic (ary), Hausa(hau), Igbo(ibo), Kinyarwanda(kin), Moroccan Arabic/Darija(arq), Mozambican Portuguese(por), Nigerian Pidgin (pcm), Oromo (oro), Swahili(swa), Tigrinya(tir), Twi(twi), Xitsonga(tso), and Yoruba(yor)).
72
+
73
+
74
+ ## Dataset Structure
75
+
76
+ ### Data Instances
77
+
78
+ For each instance, there is a string for the tweet and a string for the label. See the AfriSenti [dataset viewer](https://huggingface.co/datasets/shmuhammad/AfriSenti/viewer/shmuhammad--AfriSenti/train) to explore more examples.
79
+
80
+
81
+ ```
82
+ {
83
+ "tweet": "string",
84
+ "label": "string"
85
+ }
86
+ ```
87
+
88
+
89
+ ### Data Fields
90
+
91
+ The data fields are:
92
+
93
+ ```
94
+ tweet: a string feature.
95
+ label: a classification label, with possible values including positive, negative and neutral.
96
+ ```
97
+
98
+
99
+ ### Data Splits
100
+
101
+ The AfriSenti dataset has 3 splits: train, validation, and test. Below are the statistics for Version 1.0.0 of the dataset.
102
+
103
+ | | ama | arq | hau | ibo | ary | orm | pcm | pt-MZ | kin | swa | tir | tso | twi | yo |
104
+ |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
105
+ | train | 5,982 | 1,652 | 14,173 | 10,193 | 5,584| - | 5,122 | 3,064 | 3,303 | 1,811 | - | 805 | 3,482| 8,523 |
106
+ | dev | 1,498 | 415 | 2,678 | 1,842 | 1,216 | 397 | 1,282 | 768 | 828 | 454 | 399 | 204 | 389 | 2,091 |
107
+ | test | 2,000 | 959 | 5,304 | 3,683 | 2,962 | 2,097 | 4,155 | 3,663 | 1,027 | 749 | 2,001 | 255 | 950 | 4,516 |
108
+ | total | 9,483 | 3,062 | 22,155 | 15,718 | 9,762 | 2,494 | 10,559 | 7,495 | 5,158 | 3,014 | 2,400 | 1,264 | 4,821 | 15,130 |
109
+
110
+ ### How to use it
111
+
112
+
113
+ ```python
114
+ from datasets import load_dataset
115
+
116
+ # you can load specific languages (e.g., Amharic). This download train, validation and test sets.
117
+ ds = load_dataset("shmuhammad/AfriSenti-twitter-sentiment", "amh")
118
+
119
+ # train set only
120
+ ds = load_dataset("shmuhammad/AfriSenti-twitter-sentiment", "amh", split = "train")
121
+
122
+ # test set only
123
+ ds = load_dataset("shmuhammad/AfriSenti-twitter-sentiment", "amh", split = "test")
124
+
125
+ # validation set only
126
+ ds = load_dataset("shmuhammad/AfriSenti-twitter-sentiment", "amh", split = "validation")
127
+
128
+
129
+ ```
130
+
131
+
132
+
133
+ ## Dataset Creation
134
+
135
+ ### Curation Rationale
136
+
137
+ AfriSenti Version 1.0.0 aimed to be used in the first Afrocentric SemEval shared task **[SemEval 2023 Task 12: Sentiment analysis for African languages (AfriSenti-SemEval)](https://afrisenti-semeval.github.io)**.
138
+
139
+
140
+ ### Source Data
141
+
142
+ Twitter
143
+
144
+ #### Initial Data Collection and Normalization
145
+
146
+ [More Information Needed]
147
+
148
+ #### Who are the source language producers?
149
+
150
+ [More Information Needed]
151
+
152
+ ### Annotations
153
+
154
+ #### Annotation process
155
+
156
+ [More Information Needed]
157
+
158
+ #### Who are the annotators?
159
+
160
+
161
+
162
+ [More Information Needed]
163
+
164
+ ### Personal and Sensitive Information
165
+
166
+ We anonymized the tweets by replacing all *@mentions* by *@user* and removed all URLs.
167
+
168
+
169
+ ## Considerations for Using the Data
170
+
171
+ ### Social Impact of Dataset
172
+
173
+ The Afrisenti dataset has the potential to improve sentiment analysis for African languages, which is essential for understanding and analyzing the diverse perspectives of people in the African continent. This dataset can enable researchers and developers to create sentiment analysis models that are specific to African languages, which can be used to gain insights into the social, cultural, and political views of people in African countries. Furthermore, this dataset can help address the issue of underrepresentation of African languages in natural language processing, paving the way for more equitable and inclusive AI technologies.
174
+
175
+ [More Information Needed]
176
+
177
+ ### Discussion of Biases
178
+
179
+ [More Information Needed]
180
+
181
+ ### Other Known Limitations
182
+
183
+ [More Information Needed]
184
+
185
+ ## Additional Information
186
+
187
+ ### Dataset Curators
188
+
189
+ AfriSenti is an extension of NaijaSenti, a dataset consisting of four Nigerian languages: Hausa, Yoruba, Igbo, and Nigerian-Pidgin. This dataset has been expanded to include other 10 African languages, and was curated with the help of the following:
190
+
191
+
192
+ | Language | Dataset Curators |
193
+ |---|---|
194
+ | Algerian Arabic (arq) | Nedjma Ousidhoum, Meriem Beloucif |
195
+ | Amharic (ama) | Abinew Ali Ayele, Seid Muhie Yimam |
196
+ | Hausa (hau) | Shamsuddeen Hassan Muhammad, Idris Abdulmumin, Ibrahim Said, Bello Shehu Bello |
197
+ | Igbo (ibo) | Shamsuddeen Hassan Muhammad, Idris Abdulmumin, Ibrahim Said, Bello Shehu Bello |
198
+ | Kinyarwanda (kin)| Samuel Rutunda |
199
+ | Moroccan Arabic/Darija (ary) | Oumaima Hourrane |
200
+ | Mozambique Portuguese (pt-MZ) | Felermino Dário Mário António Ali |
201
+ | Nigerian Pidgin (pcm) | Shamsuddeen Hassan Muhammad, Idris Abdulmumin, Ibrahim Said, Bello Shehu Bello |
202
+ | Oromo (orm) | Abinew Ali Ayele, Seid Muhie Yimam, Hagos Tesfahun Gebremichael, Sisay Adugna Chala, Hailu Beshada Balcha, Wendimu Baye Messell, Tadesse Belay |
203
+ | Swahili (swa) | Davis Davis |
204
+ | Tigrinya (tir) | Abinew Ali Ayele, Seid Muhie Yimam, Hagos Tesfahun Gebremichael, Sisay Adugna Chala, Hailu Beshada Balcha, Wendimu Baye Messell, Tadesse Belay |
205
+ | Twi (twi) | Salomey Osei, Bernard Opoku, Steven Arthur |
206
+ | Xithonga (tso) | Felermino Dário Mário António Ali |
207
+ | Yoruba (yor) | Shamsuddeen Hassan Muhammad, Idris Abdulmumin, Ibrahim Said, Bello Shehu Bello |
208
+
209
+
210
+
211
+
212
+
213
+ ### Licensing Information
214
+
215
+ This AfriSenti is licensed under a Creative Commons Attribution 4.0 International License
216
+
217
+
218
+
219
+
220
+ ### Citation Information
221
+
222
+ ```
223
+ @inproceedings{Muhammad2023AfriSentiAT,
224
+ title={AfriSenti: A Twitter Sentiment Analysis Benchmark for African Languages},
225
+ author={Shamsuddeen Hassan Muhammad and Idris Abdulmumin and Abinew Ali Ayele and Nedjma Ousidhoum and David Ifeoluwa Adelani and Seid Muhie Yimam and Ibrahim Sa'id Ahmad and Meriem Beloucif and Saif Mohammad and Sebastian Ruder and Oumaima Hourrane and Pavel Brazdil and Felermino D'ario M'ario Ant'onio Ali and Davis Davis and Salomey Osei and Bello Shehu Bello and Falalu Ibrahim and Tajuddeen Gwadabe and Samuel Rutunda and Tadesse Belay and Wendimu Baye Messelle and Hailu Beshada Balcha and Sisay Adugna Chala and Hagos Tesfahun Gebremichael and Bernard Opoku and Steven Arthur},
226
+ year={2023}
227
+ }
228
+ ```
229
+
230
+
231
+ ```
232
+ @article{muhammad2023semeval,
233
+ title={SemEval-2023 Task 12: Sentiment Analysis for African Languages (AfriSenti-SemEval)},
234
+ author={Muhammad, Shamsuddeen Hassan and Abdulmumin, Idris and Yimam, Seid Muhie and Adelani, David Ifeoluwa and Ahmad, Ibrahim Sa'id and Ousidhoum, Nedjma and Ayele, Abinew and Mohammad, Saif M and Beloucif, Meriem},
235
+ journal={arXiv preprint arXiv:2304.06845},
236
+ year={2023}
237
+ }
238
+ ```
239
+
240
+
241
+ ### Contributions
242
+
243
+ [More Information Needed]
dataset_infos.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "default": {
3
+ "description": "AfriSenti is the largest sentiment analysis benchmark for under-represented languages---covering 110,000+ annotated tweets in 14 African languages (Amharic, Algerian Arabic, Hausa, Igbo, Kinyarwanda, Moroccan Arabic, Mozambican Portuguese, Nigerian Pidgin, Oromo, Swahili, Tigrinya, Twi, Xitsonga, and Yoruba) from four language families (Afro-Asiatic, English Creole, Indo-European and Niger-Congo).\n",
4
+ "citation": " ",
5
+ "homepage": "https://github.com/afrisenti-semeval/afrisent-semeval-2023",
6
+ "license": "",
7
+ "features": {
8
+ "text": {
9
+ "dtype": "string",
10
+ "id": null,
11
+ "_type": "Value"
12
+ },
13
+ "label": {
14
+ "num_classes": 3,
15
+ "names": [
16
+ "positive",
17
+ "negative",
18
+ "neutral"
19
+ ],
20
+ "names_file": null,
21
+ "id": null,
22
+ "_type": "ClassLabel"
23
+ }
24
+ },
25
+ "post_processed": null,
26
+ "supervised_keys": {
27
+ "input": "tweet",
28
+ "output": "label"
29
+ },
30
+ "task_templates": [
31
+ {
32
+ "task": "text-classification",
33
+ "text_column": "tweet",
34
+ "label_column": "label",
35
+ "labels": [
36
+ "positive",
37
+ "negative",
38
+ "neutral"
39
+ ]
40
+ }
41
+ ],
42
+ "builder_name": "AfriSenti",
43
+ "config_name": "default",
44
+ "version": {
45
+ "version_str": "0.0.0",
46
+ "description": null,
47
+ "major": 0,
48
+ "minor": 0,
49
+ "patch": 0
50
+
51
+ },
52
+ "download_size": 2069616,
53
+ "post_processing_size": null,
54
+ "dataset_size": 2173417,
55
+ "size_in_bytes": 4243033
56
+ }
57
+ }