abumafrim commited on
Commit
beadddb
·
1 Parent(s): b62aea5

Update Naija-Lexicons.py

Browse files
Files changed (1) hide show
  1. Naija-Lexicons.py +18 -18
Naija-Lexicons.py CHANGED
@@ -36,7 +36,7 @@ _CITATION = """\
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,
@@ -54,7 +54,7 @@ import pandas as pd
54
 
55
  import datasets
56
 
57
- LANGUAGES = ['hausa', 'igbo', 'yoruba']
58
 
59
  class NaijaLexiconsConfig(datasets.BuilderConfig):
60
  """BuilderConfig for NaijaLexicons"""
@@ -106,8 +106,8 @@ class NaijaLexicons(datasets.GeneratorBasedBuilder):
106
  description=textwrap.dedent(
107
  f"""{_DESCRIPTION}"""
108
  ),
109
- text_features={"word": "word", 'machine': 'machine', 'human': 'human', 'emotion_intensity_score': 'emotion_intensity_score'},
110
- label_classes=['positive', 'negative', 'surprise', 'fear', 'anticipation', 'anger', 'joy', 'trust', 'disgust', 'sadness'],
111
  label_column="label",
112
  manual_sentiment_url=f"https://raw.githubusercontent.com/hausanlp/NaijaSenti/main/data/lexicons/manual-sentiment/huggingface/{lang}.csv",
113
  translated_sentiment_url=f"https://raw.githubusercontent.com/hausanlp/NaijaSenti/main/data/lexicons/translated-sentiment/huggingface/{lang}.csv",
@@ -135,28 +135,28 @@ class NaijaLexicons(datasets.GeneratorBasedBuilder):
135
  translated_emotion_path = dl_manager.download_and_extract(self.config.translated_emotion_url)
136
 
137
  return [
138
- datasets.SplitGenerator(name='manual_sentiment', gen_kwargs={"filepath": manual_sentiment_path}),
139
- datasets.SplitGenerator(name='translated_sentiment', gen_kwargs={"filepath": translated_sentiment_path}),
140
- datasets.SplitGenerator(name='translated_emotion', gen_kwargs={"filepath": translated_emotion_path})
141
  ]
142
 
143
  def _generate_examples(self, filepath):
144
  df = pd.read_csv(filepath)
145
 
146
- print('-'*100)
147
  print(df.head())
148
- print('-'*100)
149
 
150
- if self.config.name == 'translated-sentiment':
151
  for id_, row in df.iterrows():
152
  word = row["word"]
153
- machine = row['machine']
154
- human = row['human']
155
  label = row["label"]
156
 
157
- yield id_, {"word": word, 'machine': machine, 'human': human, "label": label}
158
 
159
- elif self.config.name == 'manual-sentiment':
160
  for id_, row in df.iterrows():
161
  word = row["word"]
162
  label = row["label"]
@@ -166,9 +166,9 @@ class NaijaLexicons(datasets.GeneratorBasedBuilder):
166
  else:
167
  for id_, row in df.iterrows():
168
  word = row["word"]
169
- machine = row['machine']
170
- human = row['human']
171
  label = row["label"]
172
- emotion_intensity_score = row['emotion_intensity_score']
173
 
174
- yield id_, {"word": word, 'machine': machine, 'human': human, "label": label, 'emotion_intensity_score': emotion_intensity_score}
 
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,
 
54
 
55
  import datasets
56
 
57
+ LANGUAGES = ["hausa", "igbo", "yoruba"]
58
 
59
  class NaijaLexiconsConfig(datasets.BuilderConfig):
60
  """BuilderConfig for NaijaLexicons"""
 
106
  description=textwrap.dedent(
107
  f"""{_DESCRIPTION}"""
108
  ),
109
+ text_features={"word": "word", "machine": "machine", "human": "human", "emotion_intensity_score": "emotion_intensity_score"},
110
+ label_classes=["positive", "negative", "surprise", "fear", "anticipation", "anger", "joy", "trust", "disgust", "sadness"],
111
  label_column="label",
112
  manual_sentiment_url=f"https://raw.githubusercontent.com/hausanlp/NaijaSenti/main/data/lexicons/manual-sentiment/huggingface/{lang}.csv",
113
  translated_sentiment_url=f"https://raw.githubusercontent.com/hausanlp/NaijaSenti/main/data/lexicons/translated-sentiment/huggingface/{lang}.csv",
 
135
  translated_emotion_path = dl_manager.download_and_extract(self.config.translated_emotion_url)
136
 
137
  return [
138
+ datasets.SplitGenerator(name="manual_sentiment", gen_kwargs={"filepath": manual_sentiment_path}),
139
+ datasets.SplitGenerator(name="translated_sentiment", gen_kwargs={"filepath": translated_sentiment_path}),
140
+ datasets.SplitGenerator(name="translated_emotion", gen_kwargs={"filepath": translated_emotion_path})
141
  ]
142
 
143
  def _generate_examples(self, filepath):
144
  df = pd.read_csv(filepath)
145
 
146
+ print("-"*100)
147
  print(df.head())
148
+ print("-"*100)
149
 
150
+ if self.config.name == "translated-sentiment":
151
  for id_, row in df.iterrows():
152
  word = row["word"]
153
+ machine = row["machine"]
154
+ human = row["human"]
155
  label = row["label"]
156
 
157
+ yield id_, {"word": word, "machine": machine, "human": human, "label": label}
158
 
159
+ elif self.config.name == "manual-sentiment":
160
  for id_, row in df.iterrows():
161
  word = row["word"]
162
  label = row["label"]
 
166
  else:
167
  for id_, row in df.iterrows():
168
  word = row["word"]
169
+ machine = row["machine"]
170
+ human = row["human"]
171
  label = row["label"]
172
+ emotion_intensity_score = row["emotion_intensity_score"]
173
 
174
+ yield id_, {"word": word, "machine": machine, "human": human, "label": label, "emotion_intensity_score": emotion_intensity_score}