abumafrim commited on
Commit
674a84d
·
1 Parent(s): 2d96e95

First commit

Browse files
Files changed (2) hide show
  1. Naija-Stopwords.py +136 -0
  2. dataset_infos.json +36 -0
Naija-Stopwords.py ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ Naija-Stopwords is a part of the Naija-Senti project. It is a list of collected stopwords from the four most widely spoken languages in Nigeria — Hausa, Igbo, Nigerian-Pidgin, and Yorùbá.
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 textwrap
53
+ import pandas as pd
54
+
55
+ import datasets
56
+
57
+ LANGUAGES = ['hausa', 'igbo', 'yoruba', 'nigerian_pidgin']
58
+
59
+ class NaijaSentiConfig(datasets.BuilderConfig):
60
+ """BuilderConfig for NaijaSenti"""
61
+
62
+ def __init__(
63
+ self,
64
+ text_features,
65
+ stopwords_url,
66
+ citation,
67
+ **kwargs,
68
+ ):
69
+ """BuilderConfig for NaijaSenti.
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(NaijaSentiConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
84
+ self.text_features = text_features
85
+ self.stopwords_url = stopwords_url
86
+ self.citation = citation
87
+
88
+
89
+ class NaijaSenti(datasets.GeneratorBasedBuilder):
90
+ """NaijaSenti benchmark"""
91
+
92
+ BUILDER_CONFIGS = []
93
+
94
+ for lang in LANGUAGES:
95
+ BUILDER_CONFIGS.append(
96
+ NaijaSentiConfig(
97
+ name=lang,
98
+ description=textwrap.dedent(
99
+ f"""{_DESCRIPTION}"""
100
+ ),
101
+ text_features={"word": "word"},
102
+ stopwords_url=f"https://raw.githubusercontent.com/hausanlp/NaijaSenti/main/data/stopwords/{lang}_stopwords.csv",
103
+ citation=textwrap.dedent(
104
+ f"""{_CITATION}"""
105
+ ),
106
+ ),
107
+ )
108
+
109
+ def _info(self):
110
+ features = {text_feature: datasets.Value("string") for text_feature in self.config.text_features}
111
+
112
+ return datasets.DatasetInfo(
113
+ description=self.config.description,
114
+ features=datasets.Features(features),
115
+ citation=self.config.citation,
116
+ )
117
+
118
+ def _split_generators(self, dl_manager):
119
+ """Returns SplitGenerators."""
120
+ stpowords_path = dl_manager.download_and_extract(self.config.stopwords_url)
121
+
122
+ return [
123
+ datasets.SplitGenerator(name='stopwords', gen_kwargs={"filepath": stpowords_path})
124
+ ]
125
+
126
+ def _generate_examples(self, filepath):
127
+ df = pd.read_csv(filepath, sep='\t')
128
+
129
+ print('-'*100)
130
+ print(df.head())
131
+ print('-'*100)
132
+
133
+ for id_, row in df.iterrows():
134
+ stopword = row["word"]
135
+
136
+ yield id_, {"stopword": stopword}
dataset_infos.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "default": {
3
+ "description": "Naija-Stopwords is a part of the Naija-Senti project. It is a list of collected stopwords from the four most widely spoken languages in Nigeria — Hausa, Igbo, Nigerian-Pidgin, and Yorùbá.\n",
4
+ "citation": " ",
5
+ "homepage": "https://github.com/afrisenti-semeval/afrisent-semeval-2023",
6
+ "license": "",
7
+ "features": {
8
+ "word": {
9
+ "dtype": "string",
10
+ "id": null,
11
+ "_type": "Value"
12
+ }
13
+ },
14
+ "post_processed": null,
15
+ "task_templates": [
16
+ {
17
+ "task": "text-classification",
18
+ "word_column": "word"
19
+ }
20
+ ],
21
+ "builder_name": "Naija-Stopwords",
22
+ "config_name": "default",
23
+ "version": {
24
+ "version_str": "0.0.0",
25
+ "description": null,
26
+ "major": 0,
27
+ "minor": 0,
28
+ "patch": 0
29
+
30
+ },
31
+ "download_size": 2069616,
32
+ "post_processing_size": null,
33
+ "dataset_size": 2173417,
34
+ "size_in_bytes": 4243033
35
+ }
36
+ }