abumafrim commited on
Commit
bda0860
1 Parent(s): ea154a8

First commit

Browse files
Files changed (3) hide show
  1. NaijaSenti-Twitter.py +157 -0
  2. README.md +217 -1
  3. dataset_infos.json +57 -0
NaijaSenti-Twitter.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """NaijaSenti: A Nigerian Twitter Sentiment Corpus for Multilingual Sentiment Analysis"""
16
+
17
+
18
+
19
+ _HOMEPAGE = "https://github.com/hausanlp/NaijaSenti"
20
+
21
+ _DESCRIPTION = """\
22
+ NaijaSenti is the first large-scale human-annotated Twitter sentiment dataset for the four most widely spoken languages in Nigeria — Hausa, Igbo, Nigerian-Pidgin, and Yorùbá — consisting of around 30,000 annotated tweets per language, including a significant fraction of code-mixed tweets.
23
+ """
24
+
25
+
26
+ _CITATION = """\
27
+ @inproceedings{muhammad-etal-2022-naijasenti,
28
+ title = "{N}aija{S}enti: A {N}igerian {T}witter Sentiment Corpus for Multilingual Sentiment Analysis",
29
+ author = "Muhammad, Shamsuddeen Hassan and
30
+ Adelani, David Ifeoluwa and
31
+ Ruder, Sebastian and
32
+ Ahmad, Ibrahim Sa{'}id and
33
+ Abdulmumin, Idris and
34
+ Bello, Bello Shehu and
35
+ Choudhury, Monojit and
36
+ Emezue, Chris Chinenye and
37
+ Abdullahi, Saheed Salahudeen and
38
+ Aremu, Anuoluwapo and
39
+ Jorge, Al{\'\i}pio and
40
+ Brazdil, Pavel",
41
+ booktitle = "Proceedings of the Thirteenth Language Resources and Evaluation Conference",
42
+ month = jun,
43
+ year = "2022",
44
+ address = "Marseille, France",
45
+ publisher = "European Language Resources Association",
46
+ url = "https://aclanthology.org/2022.lrec-1.63",
47
+ pages = "590--602",
48
+ }
49
+ """
50
+
51
+
52
+ import csv
53
+ import textwrap
54
+ import pandas as pd
55
+
56
+ import datasets
57
+
58
+ LANGUAGES = ['hau', 'ibo', 'yor', 'pcm']
59
+
60
+ class NaijaSentiConfig(datasets.BuilderConfig):
61
+ """BuilderConfig for NaijaSenti"""
62
+
63
+ def __init__(
64
+ self,
65
+ text_features,
66
+ label_column,
67
+ label_classes,
68
+ train_url,
69
+ valid_url,
70
+ test_url,
71
+ citation,
72
+ **kwargs,
73
+ ):
74
+ """BuilderConfig for NaijaSenti.
75
+
76
+ Args:
77
+ text_features: `dict[string]`, map from the name of the feature
78
+ dict for each text field to the name of the column in the txt/csv/tsv file
79
+ label_column: `string`, name of the column in the txt/csv/tsv file corresponding
80
+ to the label
81
+ label_classes: `list[string]`, the list of classes if the label is categorical
82
+ train_url: `string`, url to train file from
83
+ valid_url: `string`, url to valid file from
84
+ test_url: `string`, url to test file from
85
+ citation: `string`, citation for the data set
86
+ **kwargs: keyword arguments forwarded to super.
87
+ """
88
+ super(NaijaSentiConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
89
+ self.text_features = text_features
90
+ self.label_column = label_column
91
+ self.label_classes = label_classes
92
+ self.train_url = train_url
93
+ self.valid_url = valid_url
94
+ self.test_url = test_url
95
+ self.citation = citation
96
+
97
+
98
+ class NaijaSenti(datasets.GeneratorBasedBuilder):
99
+ """NaijaSenti benchmark"""
100
+
101
+ BUILDER_CONFIGS = []
102
+
103
+ for lang in LANGUAGES:
104
+ BUILDER_CONFIGS.append(
105
+ NaijaSentiConfig(
106
+ name=lang,
107
+ description=textwrap.dedent(
108
+ f"""\
109
+ {lang} dataset."""
110
+ ),
111
+ text_features={"tweet": "tweet"},
112
+ label_classes=["positive", "neutral", "negative"],
113
+ label_column="label",
114
+ train_url=f"https://raw.githubusercontent.com/hausanlp/NaijaSenti/main/data/annotated_tweets/{lang}/train.tsv",
115
+ valid_url=f"https://raw.githubusercontent.com/hausanlp/NaijaSenti/main/data/annotated_tweets/{lang}/dev.tsv",
116
+ test_url=f"https://raw.githubusercontent.com/hausanlp/NaijaSenti/main/data/annotated_tweets/{lang}/test.tsv",
117
+ citation=textwrap.dedent(
118
+ f"""\
119
+ {lang} citation"""
120
+ ),
121
+ ),
122
+ )
123
+
124
+ def _info(self):
125
+ features = {text_feature: datasets.Value("string") for text_feature in self.config.text_features}
126
+ features["label"] = datasets.features.ClassLabel(names=self.config.label_classes)
127
+
128
+ return datasets.DatasetInfo(
129
+ description=self.config.description,
130
+ features=datasets.Features(features),
131
+ citation=self.config.citation,
132
+ )
133
+
134
+ def _split_generators(self, dl_manager):
135
+ """Returns SplitGenerators."""
136
+ train_path = dl_manager.download_and_extract(self.config.train_url)
137
+ valid_path = dl_manager.download_and_extract(self.config.valid_url)
138
+ test_path = dl_manager.download_and_extract(self.config.test_url)
139
+
140
+ return [
141
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
142
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": valid_path}),
143
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
144
+ ]
145
+
146
+ def _generate_examples(self, filepath):
147
+ df = pd.read_csv(filepath, sep='\t')
148
+
149
+ print('-'*100)
150
+ print(df.head())
151
+ print('-'*100)
152
+
153
+ for id_, row in df.iterrows():
154
+ tweet = row["tweet"]
155
+ label = row["label"]
156
+
157
+ yield id_, {"tweet": tweet, "label": label}
README.md CHANGED
@@ -1,3 +1,219 @@
1
  ---
2
- license: cc-by-sa-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ - hau
20
+ - ibo
21
+ - pcm
22
+ - yor
23
+ pretty_name: AfriSenti
24
  ---
25
+
26
+ <p align="center">
27
+ <img src="https://raw.githubusercontent.com/hausanlp/NaijaSenti/main/image/naijasenti_logo1.png", width="500">
28
+
29
+ --------------------------------------------------------------------------------
30
+
31
+ ## Dataset Description
32
+
33
+
34
+ - **Homepage:** https://github.com/hausanlp/NaijaSenti
35
+ - **Repository:** [GitHub](https://github.com/hausanlp/NaijaSenti)
36
+ - **Paper:** [NaijaSenti: A Nigerian Twitter Sentiment Corpus for Multilingual Sentiment Analysis](https://aclanthology.org/2022.lrec-1.63/)
37
+ - **Leaderboard:** N/A
38
+ - **Point of Contact:** [Shamsuddeen Hassan Muhammad](shamsuddeen2004@gmail.com)
39
+
40
+
41
+ ### Dataset Summary
42
+
43
+ NaijaSenti is the first large-scale human-annotated Twitter sentiment dataset for the four most widely spoken languages in Nigeria — Hausa, Igbo, Nigerian-Pidgin, and Yorùbá — consisting of around 30,000 annotated tweets per language, including a significant fraction of code-mixed tweets.
44
+
45
+
46
+ ### Supported Tasks and Leaderboards
47
+
48
+ The NaijaSenti can be used for a wide range of sentiment analysis tasks in Nigerian 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. It was part of the datasets that were used for [SemEval 2023 Task 12: Sentiment Analysis for African Languages](https://codalab.lisn.upsaclay.fr/competitions/7320).
49
+
50
+
51
+ ### Languages
52
+
53
+ 4 most spoken Nigerian languages
54
+
55
+ * Hausa (hau)
56
+ * Igbo (ibo)
57
+ * Nigerian Pidgin (pcm)
58
+ * Yoruba (yor)
59
+
60
+
61
+ ## Dataset Structure
62
+
63
+ ### Data Instances
64
+
65
+ For each instance, there is a string for the tweet and a string for the label. See the NaijaSenti [dataset viewer](https://huggingface.co/datasets/HausaNLP/NaijaSenti/viewer/HausaNLP--NaijaSenti/train) to explore more examples.
66
+
67
+
68
+ ```
69
+ {
70
+ "tweet": "string",
71
+ "label": "string"
72
+ }
73
+ ```
74
+
75
+
76
+ ### Data Fields
77
+
78
+ The data fields are:
79
+
80
+ ```
81
+ tweet: a string feature.
82
+ label: a classification label, with possible values including positive, negative and neutral.
83
+ ```
84
+
85
+
86
+ ### Data Splits
87
+
88
+ The NaijaSenti dataset has 3 splits: train, validation, and test. Below are the statistics for Version 1.0.0 of the dataset.
89
+
90
+ | | hau | ibo | pcm | yor |
91
+ |---|---|---|---|---|
92
+ | train | 14,172 | 10,192 | 5,121 | 8,522 |
93
+ | dev | 2,677 | 1,841 | 1,281 | 2,090 |
94
+ | test | 5,303 | 3,682 | 4,154 | 4,515 |
95
+ | total | 22,152 | 15,715 | 10,556 | 15,127 |
96
+
97
+
98
+ ### How to use it
99
+
100
+
101
+ ```python
102
+ from datasets import load_dataset
103
+
104
+ # you can load specific languages (e.g., Amharic). This download train, validation and test sets.
105
+ ds = load_dataset("HausaNLP/NaijaSenti-Twitter", "hau")
106
+
107
+ # train set only
108
+ ds = load_dataset("HausaNLP/NaijaSenti-Twitter", "hau", split = "train")
109
+
110
+ # test set only
111
+ ds = load_dataset("HausaNLP/NaijaSenti-Twitter", "hau", split = "test")
112
+
113
+ # validation set only
114
+ ds = load_dataset("HausaNLP/NaijaSenti-Twitter", "hau", split = "validation")
115
+
116
+ ```
117
+
118
+
119
+
120
+ ## Dataset Creation
121
+
122
+ ### Curation Rationale
123
+
124
+ NaijaSenti Version 1.0.0 aimed to be used sentiment analysis and other related task in Nigerian indigenous and creole languages - Hausa, Igbo, Nigerian Pidgin and Yoruba.
125
+
126
+
127
+ ### Source Data
128
+
129
+ Twitter
130
+
131
+ #### Initial Data Collection and Normalization
132
+
133
+ [More Information Needed]
134
+
135
+ #### Who are the source language producers?
136
+
137
+ [More Information Needed]
138
+
139
+ ### Annotations
140
+
141
+ #### Annotation process
142
+
143
+ [More Information Needed]
144
+
145
+ #### Who are the annotators?
146
+
147
+
148
+
149
+ [More Information Needed]
150
+
151
+ ### Personal and Sensitive Information
152
+
153
+ We anonymized the tweets by replacing all *@mentions* by *@user* and removed all URLs.
154
+
155
+
156
+ ## Considerations for Using the Data
157
+
158
+ ### Social Impact of Dataset
159
+
160
+ The NaijaSenti dataset has the potential to improve sentiment analysis for Nigerian languages, which is essential for understanding and analyzing the diverse perspectives of people in Nigeria. This dataset can enable researchers and developers to create sentiment analysis models that are specific to Nigerian languages, which can be used to gain insights into the social, cultural, and political views of people in Nigerian. Furthermore, this dataset can help address the issue of underrepresentation of Nigerian languages in natural language processing, paving the way for more equitable and inclusive AI technologies.
161
+
162
+ [More Information Needed]
163
+
164
+ ### Discussion of Biases
165
+
166
+ [More Information Needed]
167
+
168
+ ### Other Known Limitations
169
+
170
+ [More Information Needed]
171
+
172
+ ## Additional Information
173
+
174
+ ### Dataset Curators
175
+
176
+ * Shamsuddeen Hassan Muhammad
177
+ * Idris Abdulmumin
178
+ * Ibrahim Said Ahmad
179
+ * Bello Shehu Bello
180
+
181
+
182
+ ### Licensing Information
183
+
184
+ This NaijaSenti is licensed under a Creative Commons Attribution BY-NC-SA 4.0 International License
185
+
186
+
187
+
188
+
189
+ ### Citation Information
190
+
191
+ ```
192
+ @inproceedings{muhammad-etal-2022-naijasenti,
193
+ title = "{N}aija{S}enti: A {N}igerian {T}witter Sentiment Corpus for Multilingual Sentiment Analysis",
194
+ author = "Muhammad, Shamsuddeen Hassan and
195
+ Adelani, David Ifeoluwa and
196
+ Ruder, Sebastian and
197
+ Ahmad, Ibrahim Sa{'}id and
198
+ Abdulmumin, Idris and
199
+ Bello, Bello Shehu and
200
+ Choudhury, Monojit and
201
+ Emezue, Chris Chinenye and
202
+ Abdullahi, Saheed Salahudeen and
203
+ Aremu, Anuoluwapo and
204
+ Jorge, Al{\'\i}pio and
205
+ Brazdil, Pavel",
206
+ booktitle = "Proceedings of the Thirteenth Language Resources and Evaluation Conference",
207
+ month = jun,
208
+ year = "2022",
209
+ address = "Marseille, France",
210
+ publisher = "European Language Resources Association",
211
+ url = "https://aclanthology.org/2022.lrec-1.63",
212
+ pages = "590--602",
213
+ }
214
+ ```
215
+
216
+
217
+ ### Contributions
218
+
219
+ [More Information Needed]
dataset_infos.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "default": {
3
+ "description": "NaijaSenti is the first large-scale human-annotated Twitter sentiment dataset for the four most widely spoken languages in Nigeria — Hausa, Igbo, Nigerian-Pidgin, and Yorùbá — consisting of around 30,000 annotated tweets per language, including a significant fraction of code-mixed tweets.\n",
4
+ "citation": " ",
5
+ "homepage": "https://github.com/hausanlp/NaijaSenti",
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": "NaijaSenti",
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
+ }