antypasd commited on
Commit
916102c
1 Parent(s): 140e6d4

added emotion

Browse files
README.md CHANGED
@@ -113,49 +113,48 @@ The data fields are the same among all splits.
113
  - `text_start`: a `int` feature.
114
  - `text_end`: a `int` feature.
115
 
 
 
 
 
 
116
  ### Data Splits
117
 
118
  | task | description | number of instances |
119
  |:-----------------|:-----------------------------------|:----------------------|
120
- | tweet_topic | multi-label classification | 4585 / 573 / 1679 |
121
- | tweet_ner7 | sequence labeling | 4616 / 576 / 2807 |
122
- | tweet_qa | generation | 9489 / 1086 / 1203 |
123
- | tweet_intimacy | regression on a single text | 1191 / 396 / 396 |
124
  | tweet_similarity | regression on two texts | 450 / 100 / 450 |
125
- | tempo_wic | binary classification on two texts | 1427 / 395 / 1472 |
126
- | tweet_hate | multi-class classification | 5019 / 716 / 1433 |
127
  | tweet_emoji | multi-class classification | 50,000 / 5,000 / 50,000 |
128
- | tweet_sentiment | ABSA on a five-pointscale | 26632 / 4000 / 12379 |
129
  | tweet_nerd | binary classification | * / 407 / * |
 
130
 
131
 
132
  ## Evaluation Metrics
133
- #### tweet_topic
134
- ```macro-F1```
135
 
136
- #### tweet_ner7
137
- ``` ```
138
 
139
- #### tweet_qa
140
- ``` ```
141
 
 
142
 
143
- #### tweet_intimacy
144
 
145
- #### tweet_similarity
146
 
147
- #### tempo_wic
148
- ```Accuracy ```
149
 
150
- #### tweet_hate
151
 
152
- #### tweet_emoji
153
- ``` Accuracy at top 5 ```
154
 
155
- #### tweet_sentiment
156
- ``` ```
157
-
158
- #### tweet_nerd
159
 
160
 
161
 
@@ -303,4 +302,24 @@ TBA
303
  journal={arXiv preprint arXiv:2210.08129},
304
  year={2022}
305
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  ```
 
113
  - `text_start`: a `int` feature.
114
  - `text_end`: a `int` feature.
115
 
116
+ #### tweet_emotion
117
+ - `text`: a `string` feature.
118
+ - `gold_label_list`: a list of `string` feature.
119
+
120
+
121
  ### Data Splits
122
 
123
  | task | description | number of instances |
124
  |:-----------------|:-----------------------------------|:----------------------|
125
+ | tweet_topic | multi-label classification | 4,585 / 573 / 1,679 |
126
+ | tweet_ner7 | sequence labeling | 4,616 / 576 / 2,807 |
127
+ | tweet_qa | generation | 9,489 / 1,086 / 1,203 |
128
+ | tweet_intimacy | regression on a single text | 1,191 / 396 / 396 |
129
  | tweet_similarity | regression on two texts | 450 / 100 / 450 |
130
+ | tempo_wic | binary classification on two texts | 1,427 / 395 / 1,472 |
131
+ | tweet_hate | multi-class classification | 5,019 / 716 / 1,433 |
132
  | tweet_emoji | multi-class classification | 50,000 / 5,000 / 50,000 |
133
+ | tweet_sentiment | ABSA on a five-pointscale | 26,632 / 4,000 / 12,379 |
134
  | tweet_nerd | binary classification | * / 407 / * |
135
+ | tweet_emotion | multi-label classification | 6,838 / 886 / 3,259 |
136
 
137
 
138
  ## Evaluation Metrics
139
+ - __tweet_topic:__ ```macro-F1```
 
140
 
141
+ - __tweet_ner7:__ ```TBA```
 
142
 
143
+ - __tweet_qa:__ ```TBA```
 
144
 
145
+ - __tweet_intimacy:__ ```TBA```
146
 
147
+ - __tweet_similarity:__ ```TBA```
148
 
149
+ - __tempo_wic:__ ```Accuracy ```
150
 
151
+ - __tweet_hate:__ ```TBA```
 
152
 
153
+ - __tweet_emoji:__ ``` Accuracy at top 5 ```
154
 
155
+ - __tweet_sentiment:__ ```TBA```
 
156
 
157
+ - __tweet_nerd:__ ```TBA```
 
 
 
158
 
159
 
160
 
 
302
  journal={arXiv preprint arXiv:2210.08129},
303
  year={2022}
304
  }
305
+ ```
306
+
307
+ - TweetEmotion
308
+ ```
309
+ @inproceedings{mohammad-etal-2018-semeval,
310
+ title = "{S}em{E}val-2018 Task 1: Affect in Tweets",
311
+ author = "Mohammad, Saif and
312
+ Bravo-Marquez, Felipe and
313
+ Salameh, Mohammad and
314
+ Kiritchenko, Svetlana",
315
+ booktitle = "Proceedings of the 12th International Workshop on Semantic Evaluation",
316
+ month = jun,
317
+ year = "2018",
318
+ address = "New Orleans, Louisiana",
319
+ publisher = "Association for Computational Linguistics",
320
+ url = "https://aclanthology.org/S18-1001",
321
+ doi = "10.18653/v1/S18-1001",
322
+ pages = "1--17",
323
+ abstract = "We present the SemEval-2018 Task 1: Affect in Tweets, which includes an array of subtasks on inferring the affectual state of a person from their tweet. For each task, we created labeled data from English, Arabic, and Spanish tweets. The individual tasks are: 1. emotion intensity regression, 2. emotion intensity ordinal classification, 3. valence (sentiment) regression, 4. valence ordinal classification, and 5. emotion classification. Seventy-five teams (about 200 team members) participated in the shared task. We summarize the methods, resources, and tools used by the participating teams, with a focus on the techniques and resources that are particularly useful. We also analyze systems for consistent bias towards a particular race or gender. The data is made freely available to further improve our understanding of how people convey emotions through language.",
324
+ }
325
  ```
data/tweet_emotion/map.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ anger,0
2
+ anticipation,1
3
+ disgust,2
4
+ fear,3
5
+ joy,4
6
+ love,5
7
+ optimism,6
8
+ pessimism,7
9
+ sadness,8
10
+ surprise,9
11
+ trust,10
data/tweet_emotion/test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/tweet_emotion/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/tweet_emotion/validation.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
process/tweet_emotion.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import urllib
3
+
4
+
5
+ # format text
6
+ def clean_text(text):
7
+ text = text.replace('\n', ' ').replace('\r', ' ').replace('\t', ' ')
8
+
9
+ new_text = []
10
+ for t in text.split():
11
+ # MAKE SURE to check lowercase
12
+ t = '@user' if t.startswith('@') and len(t) > 1 and t.replace(
13
+ '@', '').lower() not in verified_users else t
14
+ t = '{URL}' if t.startswith('http') else t
15
+ new_text.append(t)
16
+
17
+ return ' '.join(new_text)
18
+
19
+
20
+ train = pd.read_csv('./emotion/2018-E-c-En-train.txt', sep='\t')
21
+ validation = pd.read_csv('./emotion/2018-E-c-En-dev.txt', sep='\t')
22
+ test = pd.read_csv('./emotion/2018-E-c-En-test-gold.txt', sep='\t')
23
+
24
+ sem_emotions = train.columns.difference(['ID', 'Tweet', 'split', 'dataset'])
25
+
26
+ # keep class mapping
27
+ with open('../data/tweet_emotion/map.txt', 'w') as f:
28
+ for idx, em in enumerate(sem_emotions):
29
+ f.write(f'{em},{idx}\n')
30
+
31
+
32
+ cols_to_keep = ['text', 'gold_label_list']
33
+ # get list of verified users
34
+ verified_users = urllib.request.urlopen(
35
+ 'https://raw.githubusercontent.com/cardiffnlp/timelms/main/data/verified_users.v091122.txt').readlines()
36
+ verified_users = [x.decode().strip('\n').lower() for x in verified_users]
37
+
38
+ # clean datasets
39
+ train['gold_label_list'] = train[sem_emotions].values.tolist()
40
+ train['text'] = train['Tweet']
41
+ train['text'] = train['text'].apply(clean_text)
42
+ train[cols_to_keep].to_json('../data/tweet_emotion/train.jsonl', lines=True, orient='records')
43
+
44
+ validation['gold_label_list'] = validation[sem_emotions].values.tolist()
45
+ validation['text'] = validation['Tweet']
46
+ validation['text'] = validation['text'].apply(clean_text)
47
+ validation[cols_to_keep].to_json('../data/tweet_emotion/validation.jsonl', lines=True, orient='records')
48
+
49
+ test['gold_label_list'] = test[sem_emotions].values.tolist()
50
+ test['text'] = test['Tweet']
51
+ test['text'] = test['text'].apply(clean_text)
52
+ test[cols_to_keep].to_json('../data/tweet_emotion/test.jsonl', lines=True, orient='records')
super_tweeteval.py CHANGED
@@ -2,7 +2,7 @@
2
  import json
3
  import datasets
4
 
5
- _VERSION = "0.1.42"
6
  _SUPER_TWEETEVAL_CITATION = """TBA"""
7
  _SUPER_TWEETEVAL_DESCRIPTION = """TBA"""
8
  _TWEET_TOPIC_DESCRIPTION = """
@@ -151,6 +151,25 @@ _TWEET_SENTIMENT_CITATION = """\
151
  abstract = "This paper describes the fifth year of the Sentiment Analysis in Twitter task. SemEval-2017 Task 4 continues with a rerun of the subtasks of SemEval-2016 Task 4, which include identifying the overall sentiment of the tweet, sentiment towards a topic with classification on a two-point and on a five-point ordinal scale, and quantification of the distribution of sentiment towards a topic across a number of tweets: again on a two-point and on a five-point ordinal scale. Compared to 2016, we made two changes: (i) we introduced a new language, Arabic, for all subtasks, and (ii) we made available information from the profiles of the Twitter users who posted the target tweets. The task continues to be very popular, with a total of 48 teams participating this year.",
152
  }
153
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
 
156
  class SuperTweetEvalConfig(datasets.BuilderConfig):
@@ -170,7 +189,8 @@ class SuperTweetEvalConfig(datasets.BuilderConfig):
170
  'False' or 'True'.
171
  **kwargs: keyword arguments forwarded to super.
172
  """
173
- super(SuperTweetEvalConfig, self).__init__(version=datasets.Version(_VERSION), **kwargs)
 
174
  self.features = features
175
  self.label_classes = label_classes
176
  self.data_url = data_url
@@ -243,7 +263,8 @@ class SuperTweetEval(datasets.GeneratorBasedBuilder):
243
  name="tweet_nerd",
244
  description=_TWEET_NERD_DESCRIPTION,
245
  citation=_TWEET_NERD_CITATION,
246
- features=['gold_label_binary', 'target', 'context', 'definition', 'text_start', 'text_end'],
 
247
  data_url="https://huggingface.co/datasets/cardiffnlp/super_tweet_eval/resolve/main/data/tweet_nerd",
248
  ),
249
  SuperTweetEvalConfig(
@@ -259,24 +280,35 @@ class SuperTweetEval(datasets.GeneratorBasedBuilder):
259
  citation=_TWEET_SENTIMENT_CITATION,
260
  features=['gold_label', 'target', 'text'],
261
  data_url="https://huggingface.co/datasets/cardiffnlp/super_tweet_eval/resolve/main/data/tweet_sentiment",
 
 
 
 
 
 
 
262
  )
263
  ]
264
 
265
  def _info(self):
266
- features = {feature: datasets.Value("string") for feature in self.config.features}
 
267
  if self.config.name == "tweet_topic":
268
  names = [
269
  "arts_&_culture", "business_&_entrepreneurs", "celebrity_&_pop_culture", "diaries_&_daily_life",
270
  "family", "fashion_&_style", "film_tv_&_video", "fitness_&_health", "food_&_dining", "gaming",
271
  "learning_&_educational", "music", "news_&_social_concern", "other_hobbies", "relationships",
272
  "science_&_technology", "sports", "travel_&_adventure", "youth_&_student_life"]
273
- features["gold_label_list"] = datasets.Sequence(datasets.features.ClassLabel(names=names))
 
274
  if self.config.name == "tweet_ner7":
275
  names = [
276
  'B-corporation', 'B-creative_work', 'B-event', 'B-group', 'B-location', 'B-person', 'B-product',
277
  'I-corporation', 'I-creative_work', 'I-event', 'I-group', 'I-location', 'I-person', 'I-product', 'O']
278
- features["gold_label_sequence"] = datasets.Sequence(datasets.features.ClassLabel(names=names))
279
- features["text_tokenized"] = datasets.Sequence(datasets.Value("string"))
 
 
280
  if self.config.name in ["tweet_intimacy", "tweet_similarity"]:
281
  features["gold_score"] = datasets.Value("float32")
282
  if self.config.name == "tempo_wic":
@@ -285,15 +317,18 @@ class SuperTweetEval(datasets.GeneratorBasedBuilder):
285
  features["text_start_2"] = datasets.Value("int32")
286
  features["text_end_1"] = datasets.Value("int32")
287
  features["text_end_2"] = datasets.Value("int32")
288
- features["text_1_tokenized"] = datasets.Sequence(datasets.Value("string"))
289
- features["text_2_tokenized"] = datasets.Sequence(datasets.Value("string"))
 
 
290
  features['date_1'] = datasets.Value("string")
291
  features['date_2'] = datasets.Value("string")
292
  if self.config.name == "tweet_hate":
293
  label_classes = [
294
- 'hate_gender', 'hate_race', 'hate_sexuality', 'hate_religion','hate_origin', 'hate_disability',
295
- 'hate_age', 'not_hate']
296
- features['gold_label'] = datasets.features.ClassLabel(names=label_classes)
 
297
  features["text"] = datasets.Value("string")
298
  if self.config.name == "tweet_nerd":
299
  features['target'] = datasets.Value("string")
@@ -309,13 +344,17 @@ class SuperTweetEval(datasets.GeneratorBasedBuilder):
309
  with open(dl_manager.download(url_map)) as f:
310
  label_classes = f.readlines()
311
  label_classes = [x.strip('\n') for x in label_classes]
312
- features['gold_label'] = datasets.features.ClassLabel(names=label_classes)
 
313
  features["text"] = datasets.Value("string")
314
  if self.config.name == "tweet_sentiment":
315
- label_classes = ["strongly negative", "negative", "negative or neutral", "positive", "strongly positive"]
316
- features['gold_label'] = datasets.features.ClassLabel(names=label_classes)
317
  features["text"] = datasets.Value("string")
318
- features["target"] = datasets.Value("string")
 
 
 
319
 
320
  return datasets.DatasetInfo(
321
  description=_SUPER_TWEETEVAL_DESCRIPTION + "\n" + self.config.description,
@@ -324,8 +363,9 @@ class SuperTweetEval(datasets.GeneratorBasedBuilder):
324
  )
325
 
326
  def _split_generators(self, dl_manager):
327
- splits = ['train', 'test', 'validation']
328
- downloaded_file = dl_manager.download_and_extract({s: f"{self.config.data_url}/{s}.jsonl" for s in splits})
 
329
  return [datasets.SplitGenerator(name=s, gen_kwargs={"filepath": downloaded_file[s]}) for s in splits]
330
 
331
  def _generate_examples(self, filepath):
 
2
  import json
3
  import datasets
4
 
5
+ _VERSION = "0.1.43"
6
  _SUPER_TWEETEVAL_CITATION = """TBA"""
7
  _SUPER_TWEETEVAL_DESCRIPTION = """TBA"""
8
  _TWEET_TOPIC_DESCRIPTION = """
 
151
  abstract = "This paper describes the fifth year of the Sentiment Analysis in Twitter task. SemEval-2017 Task 4 continues with a rerun of the subtasks of SemEval-2016 Task 4, which include identifying the overall sentiment of the tweet, sentiment towards a topic with classification on a two-point and on a five-point ordinal scale, and quantification of the distribution of sentiment towards a topic across a number of tweets: again on a two-point and on a five-point ordinal scale. Compared to 2016, we made two changes: (i) we introduced a new language, Arabic, for all subtasks, and (ii) we made available information from the profiles of the Twitter users who posted the target tweets. The task continues to be very popular, with a total of 48 teams participating this year.",
152
  }
153
  """
154
+ _TWEET_EMOTION_DESCRIPTION = """TBA"""
155
+ _TWEET_EMOTION_CITATION = """\
156
+ @inproceedings{mohammad-etal-2018-semeval,
157
+ title = "{S}em{E}val-2018 Task 1: Affect in Tweets",
158
+ author = "Mohammad, Saif and
159
+ Bravo-Marquez, Felipe and
160
+ Salameh, Mohammad and
161
+ Kiritchenko, Svetlana",
162
+ booktitle = "Proceedings of the 12th International Workshop on Semantic Evaluation",
163
+ month = jun,
164
+ year = "2018",
165
+ address = "New Orleans, Louisiana",
166
+ publisher = "Association for Computational Linguistics",
167
+ url = "https://aclanthology.org/S18-1001",
168
+ doi = "10.18653/v1/S18-1001",
169
+ pages = "1--17",
170
+ abstract = "We present the SemEval-2018 Task 1: Affect in Tweets, which includes an array of subtasks on inferring the affectual state of a person from their tweet. For each task, we created labeled data from English, Arabic, and Spanish tweets. The individual tasks are: 1. emotion intensity regression, 2. emotion intensity ordinal classification, 3. valence (sentiment) regression, 4. valence ordinal classification, and 5. emotion classification. Seventy-five teams (about 200 team members) participated in the shared task. We summarize the methods, resources, and tools used by the participating teams, with a focus on the techniques and resources that are particularly useful. We also analyze systems for consistent bias towards a particular race or gender. The data is made freely available to further improve our understanding of how people convey emotions through language.",
171
+ }
172
+ """
173
 
174
 
175
  class SuperTweetEvalConfig(datasets.BuilderConfig):
 
189
  'False' or 'True'.
190
  **kwargs: keyword arguments forwarded to super.
191
  """
192
+ super(SuperTweetEvalConfig, self).__init__(
193
+ version=datasets.Version(_VERSION), **kwargs)
194
  self.features = features
195
  self.label_classes = label_classes
196
  self.data_url = data_url
 
263
  name="tweet_nerd",
264
  description=_TWEET_NERD_DESCRIPTION,
265
  citation=_TWEET_NERD_CITATION,
266
+ features=['gold_label_binary', 'target', 'context',
267
+ 'definition', 'text_start', 'text_end'],
268
  data_url="https://huggingface.co/datasets/cardiffnlp/super_tweet_eval/resolve/main/data/tweet_nerd",
269
  ),
270
  SuperTweetEvalConfig(
 
280
  citation=_TWEET_SENTIMENT_CITATION,
281
  features=['gold_label', 'target', 'text'],
282
  data_url="https://huggingface.co/datasets/cardiffnlp/super_tweet_eval/resolve/main/data/tweet_sentiment",
283
+ ),
284
+ SuperTweetEvalConfig(
285
+ name="tweet_emotion",
286
+ description=_TWEET_EMOTION_DESCRIPTION,
287
+ citation=_TWEET_EMOTION_CITATION,
288
+ features=["text", "gold_label_list"],
289
+ data_url="https://huggingface.co/datasets/cardiffnlp/super_tweet_eval/resolve/main/data/tweet_emotion",
290
  )
291
  ]
292
 
293
  def _info(self):
294
+ features = {feature: datasets.Value(
295
+ "string") for feature in self.config.features}
296
  if self.config.name == "tweet_topic":
297
  names = [
298
  "arts_&_culture", "business_&_entrepreneurs", "celebrity_&_pop_culture", "diaries_&_daily_life",
299
  "family", "fashion_&_style", "film_tv_&_video", "fitness_&_health", "food_&_dining", "gaming",
300
  "learning_&_educational", "music", "news_&_social_concern", "other_hobbies", "relationships",
301
  "science_&_technology", "sports", "travel_&_adventure", "youth_&_student_life"]
302
+ features["gold_label_list"] = datasets.Sequence(
303
+ datasets.features.ClassLabel(names=names))
304
  if self.config.name == "tweet_ner7":
305
  names = [
306
  'B-corporation', 'B-creative_work', 'B-event', 'B-group', 'B-location', 'B-person', 'B-product',
307
  'I-corporation', 'I-creative_work', 'I-event', 'I-group', 'I-location', 'I-person', 'I-product', 'O']
308
+ features["gold_label_sequence"] = datasets.Sequence(
309
+ datasets.features.ClassLabel(names=names))
310
+ features["text_tokenized"] = datasets.Sequence(
311
+ datasets.Value("string"))
312
  if self.config.name in ["tweet_intimacy", "tweet_similarity"]:
313
  features["gold_score"] = datasets.Value("float32")
314
  if self.config.name == "tempo_wic":
 
317
  features["text_start_2"] = datasets.Value("int32")
318
  features["text_end_1"] = datasets.Value("int32")
319
  features["text_end_2"] = datasets.Value("int32")
320
+ features["text_1_tokenized"] = datasets.Sequence(
321
+ datasets.Value("string"))
322
+ features["text_2_tokenized"] = datasets.Sequence(
323
+ datasets.Value("string"))
324
  features['date_1'] = datasets.Value("string")
325
  features['date_2'] = datasets.Value("string")
326
  if self.config.name == "tweet_hate":
327
  label_classes = [
328
+ 'hate_gender', 'hate_race', 'hate_sexuality', 'hate_religion', 'hate_origin', 'hate_disability',
329
+ 'hate_age', 'not_hate']
330
+ features['gold_label'] = datasets.features.ClassLabel(
331
+ names=label_classes)
332
  features["text"] = datasets.Value("string")
333
  if self.config.name == "tweet_nerd":
334
  features['target'] = datasets.Value("string")
 
344
  with open(dl_manager.download(url_map)) as f:
345
  label_classes = f.readlines()
346
  label_classes = [x.strip('\n') for x in label_classes]
347
+ features['gold_label'] = datasets.features.ClassLabel(
348
+ names=label_classes)
349
  features["text"] = datasets.Value("string")
350
  if self.config.name == "tweet_sentiment":
351
+ label_classes = ["strongly negative", "negative",
352
+ "negative or neutral", "positive", "strongly positive"]
353
  features["text"] = datasets.Value("string")
354
+ names = ['anger', 'anticipation', 'disgust', 'fear', 'joy',
355
+ 'love', 'optimism', 'pessimism', 'sadness', 'surprise', 'trust']
356
+ features["gold_label_list"] = datasets.Sequence(
357
+ datasets.features.ClassLabel(names=names))
358
 
359
  return datasets.DatasetInfo(
360
  description=_SUPER_TWEETEVAL_DESCRIPTION + "\n" + self.config.description,
 
363
  )
364
 
365
  def _split_generators(self, dl_manager):
366
+ splits = ['train', 'test', 'validation']
367
+ downloaded_file = dl_manager.download_and_extract(
368
+ {s: f"{self.config.data_url}/{s}.jsonl" for s in splits})
369
  return [datasets.SplitGenerator(name=s, gen_kwargs={"filepath": downloaded_file[s]}) for s in splits]
370
 
371
  def _generate_examples(self, filepath):