Datasets:

Languages:
Yoruba
Multilinguality:
monolingual
Size Categories:
1K<n<10K
Language Creators:
found
Annotations Creators:
expert-generated
Source Datasets:
original
ArXiv:
License:
ToluClassics commited on
Commit
4303f6f
1 Parent(s): 81df0aa

Add a script to load the data

Browse files
Files changed (1) hide show
  1. YOSM.py +111 -0
YOSM.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """YOSM: A NEW YORUBA SENTIMENT CORPUS FOR MOVIE REVIEWS"""
18
+
19
+ import datasets
20
+ import json
21
+ import pandas as pd
22
+
23
+ logger = datasets.logging.get_logger(__name__)
24
+
25
+ _CITATION = """\
26
+ @inproceedings{
27
+ shode2022yosm,
28
+ title={{YOSM}: A {NEW} {YORUBA} {SENTIMENT} {CORPUS} {FOR} {MOVIE} {REVIEWS}},
29
+ author={Iyanuoluwa Shode and David Ifeoluwa Adelani and Anna Feldman},
30
+ booktitle={3rd Workshop on African Natural Language Processing},
31
+ year={2022},
32
+ url={https://openreview.net/forum?id=rRzx5qzVIb9}
33
+ }
34
+ """
35
+
36
+ _DESCRIPTION = """\
37
+ YOSM: A NEW YORUBA SENTIMENT CORPUS FOR MOVIE REVIEWS
38
+ - Yoruba
39
+ """
40
+
41
+ languages=[
42
+ 'yoruba'
43
+ ]
44
+
45
+ _URL = "https://github.com/IyanuSh/YOSM"
46
+ _TRAINING_FILE = "train.tsv"
47
+ _DEV_FILE = "dev.tsv"
48
+ _TEST_FILE = "test.tsv"
49
+
50
+ class Yosm(datasets.GeneratorBasedBuilder):
51
+ BUILDER_CONFIGS = [
52
+ datasets.BuilderConfig(
53
+ version=datasets.Version('1.0.0'),
54
+ name=lang,
55
+ description='YOSM: A NEW YORUBA SENTIMENT CORPUS FOR MOVIE REVIEWS'
56
+ ) for lang in languages
57
+ ]
58
+
59
+ def _info(self):
60
+ features = datasets.features({
61
+ 'yo_review': datasets.Value('string'),
62
+ 'sentiment': datasets.Value('string')
63
+ })
64
+
65
+ return datasets.DatasetInfo(
66
+ # This is the description that will appear on the datasets page.
67
+ description=_DESCRIPTION,
68
+ # This defines the different columns of the dataset and their types
69
+ features=features, # Here we define them above because they are different between the two configurations
70
+ supervised_keys=None,
71
+ # Homepage of the dataset for documentation
72
+ homepage=_URL,
73
+ # License for the dataset if available
74
+ license='',
75
+ # Citation for the dataset
76
+ citation=_CITATION,
77
+ )
78
+
79
+ def _split_generators(self, dl_manager):
80
+ lang = self.config.name
81
+
82
+ splits = [
83
+ datasets.SplitGenerator(
84
+ name='train',
85
+ gen_kwargs={
86
+ 'filepath': _TRAINING_FILE,
87
+ },
88
+ ),
89
+ datasets.SplitGenerator(
90
+ name='dev',
91
+ gen_kwargs={
92
+ 'filepath': _DEV_FILE,
93
+ },
94
+ ),
95
+ datasets.SplitGenerator(
96
+ name='test',
97
+ gen_kwargs={
98
+ 'filepath': _TEST_FILE,
99
+ },
100
+ )
101
+
102
+ ]
103
+ return splits
104
+
105
+ def _generate_examples(self, filepath):
106
+ yosm_df = pd.read_csv(filepath, sep="\t", lineterminator='\n')
107
+ for index, row in yosm_df.iterrows():
108
+ yield row["yo_review"], row["sentiment"]
109
+
110
+
111
+