asahi417 commited on
Commit
f4ef793
1 Parent(s): 750cd64
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ misc
NOTE.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+
2
+ ## Link to the Original Dataset
3
+ - TweetTopic: [link](https://huggingface.co/datasets/cardiffnlp/tweet_topic_multi)
4
+ - TweetNER: [link](https://huggingface.co/datasets/tner/tweetner7)
5
+ - TweetQA: [link](https://huggingface.co/datasets/tweet_qa), [link2](https://huggingface.co/datasets/lmqg/qg_tweetqa)
6
+ - TweetIntimacy: [link]()
7
+
data/tweet_topic/test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/tweet_topic/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/tweet_topic/validation.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
process/tweet_intimacy.py ADDED
File without changes
process/tweet_ner.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ from datasets import load_dataset
4
+
5
+ os.makedirs("data/tweet_ner7", exist_ok=True)
6
+ data = load_dataset("tner/tweetner7")
7
+
8
+
9
+ def process(tmp):
10
+ tmp.pop("label_name")
11
+ tmp = [i.to_dict() for _, i in tmp.iterrows()]
12
+ for i in tmp:
13
+ i['label_sequence'] = i.pop('tags').tolist()
14
+ i['text_tokenized'] = i.pop('token').tolist()
15
+ return tmp
16
+
17
+ train = process(data["train_2020"].to_pandas())
18
+ val = process(data["validation_2020"].to_pandas())
19
+ test = process(data["test_2021"].to_pandas())
20
+ with open("data/tweet_ner7/train.jsonl", "w") as f:
21
+ f.write("\n".join([json.dumps(i) for i in train]))
22
+ with open("data/tweet_ner7/validation.jsonl", "w") as f:
23
+ f.write("\n".join([json.dumps(i) for i in val]))
24
+ with open("data/tweet_ner7/test.jsonl", "w") as f:
25
+ f.write("\n".join([json.dumps(i) for i in test]))
26
+
27
+
28
+
process/tweet_qa.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ from datasets import load_dataset
4
+
5
+ os.makedirs("data/tweet_qa", exist_ok=True)
6
+ data = load_dataset("lmqg/qg_tweetqa")
7
+
8
+
9
+ def process(tmp):
10
+ tmp.pop("label_name")
11
+ tmp = [i.to_dict() for _, i in tmp.iterrows()]
12
+ for i in tmp:
13
+ i['text'] = i.pop('paragraph_question')
14
+ i['label_str'] = i.pop('answer')
15
+ return tmp
16
+
17
+ train = process(data["train"].to_pandas())
18
+ val = process(data["validation"].to_pandas())
19
+ test = process(data["test"].to_pandas())
20
+ with open("data/tweet_qa/train.jsonl", "w") as f:
21
+ f.write("\n".join([json.dumps(i) for i in train]))
22
+ with open("data/tweet_qa/validation.jsonl", "w") as f:
23
+ f.write("\n".join([json.dumps(i) for i in val]))
24
+ with open("data/tweet_qa/test.jsonl", "w") as f:
25
+ f.write("\n".join([json.dumps(i) for i in test]))
26
+
27
+
28
+
process/tweet_topic.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ from datasets import load_dataset
4
+
5
+ os.makedirs("data/tweet_topic", exist_ok=True)
6
+ data = load_dataset("cardiffnlp/tweet_topic_multi")
7
+
8
+
9
+ def process(tmp):
10
+ tmp.pop("label_name")
11
+ tmp = [i.to_dict() for _, i in tmp.iterrows()]
12
+ for i in tmp:
13
+ i['label_list'] = i.pop('label').tolist()
14
+ return tmp
15
+
16
+ train = process(data["train_2020"].to_pandas())
17
+ val = process(data["validation_2020"].to_pandas())
18
+ test = process(data["test_2021"].to_pandas())
19
+ with open("data/tweet_topic/train.jsonl", "w") as f:
20
+ f.write("\n".join([json.dumps(i) for i in train]))
21
+ with open("data/tweet_topic/validation.jsonl", "w") as f:
22
+ f.write("\n".join([json.dumps(i) for i in val]))
23
+ with open("data/tweet_topic/test.jsonl", "w") as f:
24
+ f.write("\n".join([json.dumps(i) for i in test]))
25
+
26
+
27
+
super_tweet_eval.py ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """The SuperTweetEval benchmark."""
2
+
3
+
4
+ import json
5
+ import os
6
+
7
+ import datasets
8
+
9
+
10
+ _SUPER_TWEET_EVAL_CITATION = """TBA"""
11
+ _SUPER_TWEET_EVAL_DESCRIPTION = """TBA"""
12
+ _TWEET_TOPIC_DESCRIPTION = """
13
+ TweetTopic is a multi-label twitter topic classification task, where each example consists of a tweet
14
+ and a set of topics. One tweet can be associated with multiple topics, and the training/validation tweets are taken
15
+ from September 2019 to August 2020, while the test tweets are taken from September 2020 to August 2021.
16
+ Following the original work, we evaluate with macro F1 score."""
17
+ _TWEET_TOPIC_CITATION = """\
18
+ @inproceedings{antypas-etal-2022-twitter,
19
+ title = "{T}witter Topic Classification",
20
+ author = "Antypas, Dimosthenis and
21
+ Ushio, Asahi and
22
+ Camacho-Collados, Jose and
23
+ Silva, Vitor and
24
+ Neves, Leonardo and
25
+ Barbieri, Francesco",
26
+ booktitle = "Proceedings of the 29th International Conference on Computational Linguistics",
27
+ month = oct,
28
+ year = "2022",
29
+ address = "Gyeongju, Republic of Korea",
30
+ publisher = "International Committee on Computational Linguistics",
31
+ url = "https://aclanthology.org/2022.coling-1.299",
32
+ pages = "3386--3400",
33
+ abstract = "Social media platforms host discussions about a wide variety of topics that arise everyday. Making sense of all the content and organising it into categories is an arduous task. A common way to deal with this issue is relying on topic modeling, but topics discovered using this technique are difficult to interpret and can differ from corpus to corpus. In this paper, we present a new task based on tweet topic classification and release two associated datasets. Given a wide range of topics covering the most important discussion points in social media, we provide training and testing data from recent time periods that can be used to evaluate tweet classification models. Moreover, we perform a quantitative evaluation and analysis of current general- and domain-specific language models on the task, which provide more insights on the challenges and nature of the task.",
34
+ }
35
+ """
36
+ _TWEET_NER7_DESCRIPTION = """
37
+ TweetNER is a named-entity recognition dataset on Twitter. The training/validation tweets are taken
38
+ from September 2019 to August 2020, while the test tweets are taken from September 2020 to August 2021.
39
+ Following the original work, we evaluate with span F1 score.
40
+ """
41
+ _TWEET_NER7_CITATION = """\
42
+ @inproceedings{ushio-etal-2022-named,
43
+ title = "Named Entity Recognition in {T}witter: A Dataset and Analysis on Short-Term Temporal Shifts",
44
+ author = "Ushio, Asahi and
45
+ Barbieri, Francesco and
46
+ Sousa, Vitor and
47
+ Neves, Leonardo and
48
+ Camacho-Collados, Jose",
49
+ booktitle = "Proceedings of the 2nd Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 12th International Joint Conference on Natural Language Processing (Volume 1: Long Papers)",
50
+ month = nov,
51
+ year = "2022",
52
+ address = "Online only",
53
+ publisher = "Association for Computational Linguistics",
54
+ url = "https://aclanthology.org/2022.aacl-main.25",
55
+ pages = "309--319",
56
+ abstract = "Recent progress in language model pre-training has led to important improvements in Named Entity Recognition (NER). Nonetheless, this progress has been mainly tested in well-formatted documents such as news, Wikipedia, or scientific articles. In social media the landscape is different, in which it adds another layer of complexity due to its noisy and dynamic nature. In this paper, we focus on NER in Twitter, one of the largest social media platforms, and construct a new NER dataset, TweetNER7, which contains seven entity types annotated over 11,382 tweets from September 2019 to August 2021. The dataset was constructed by carefully distributing the tweets over time and taking representative trends as a basis. Along with the dataset, we provide a set of language model baselines and perform an analysis on the language model performance on the task, especially analyzing the impact of different time periods. In particular, we focus on three important temporal aspects in our analysis: short-term degradation of NER models over time, strategies to fine-tune a language model over different periods, and self-labeling as an alternative to lack of recently-labeled data. TweetNER7 is released publicly (https://huggingface.co/datasets/tner/tweetner7) along with the models fine-tuned on it (NER models have been integrated into TweetNLP and can be found at https://github.com/asahi417/tner/tree/master/examples/tweetner7{\_}paper).",
57
+ }
58
+ """
59
+ _TWEET_QA_DESCRIPTION = """\
60
+ TweetQA is am abstractive question-answering dataset on Twitter.
61
+ """
62
+ _TWEET_QA_CITATION = """\
63
+ @inproceedings{xiong2019tweetqa,
64
+ title={TweetQA: A Social Media Focused Question Answering Dataset},
65
+ author={Xiong, Wenhan and Wu, Jiawei and Wang, Hong and Kulkarni, Vivek and Yu, Mo and Guo, Xiaoxiao and Chang, Shiyu and Wang, William Yang},
66
+ booktitle={Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics},
67
+ year={2019}
68
+ }
69
+ """
70
+
71
+
72
+ class SuperTweetEvalConfig(datasets.BuilderConfig):
73
+ """BuilderConfig for SuperTweetEval."""
74
+
75
+ def __init__(self, features, data_url, citation, label_classes=("False", "True"), **kwargs):
76
+ """BuilderConfig for SuperTweetEval.
77
+
78
+ Args:
79
+ features: `list[string]`, list of the features that will appear in the
80
+ feature dict. Should not include "label".
81
+ data_url: `string`, url to download the zip file from.
82
+ citation: `string`, citation for the data set.
83
+ url: `string`, url for information about the data set.
84
+ label_classes: `list[string]`, the list of classes for the label if the
85
+ label is present as a string. Non-string labels will be cast to either
86
+ 'False' or 'True'.
87
+ **kwargs: keyword arguments forwarded to super.
88
+ """
89
+ super(SuperTweetEvalConfig, self).__init__(version=datasets.Version("1.0.3"), **kwargs)
90
+ self.features = features
91
+ self.label_classes = label_classes
92
+ self.data_url = data_url
93
+ self.citation = citation
94
+
95
+
96
+ class SuperTweetEval(datasets.GeneratorBasedBuilder):
97
+ """The SuperTweetEval benchmark."""
98
+
99
+ BUILDER_CONFIGS = [
100
+ SuperTweetEvalConfig(
101
+ name="tweet_topic",
102
+ description=_TWEET_TOPIC_DESCRIPTION,
103
+ citation=_TWEET_TOPIC_CITATION,
104
+ features=["text", "label_list", "id", "date"],
105
+ data_url="https://dl.fbaipublicfiles.com/glue/SuperTweetEval/data/v2/BoolQ.zip",
106
+ ),
107
+ SuperTweetEvalConfig(
108
+ name="tweet_ner7",
109
+ description=_TWEET_NER7_DESCRIPTION,
110
+ citation=_TWEET_NER7_CITATION,
111
+ features=["text_tokenized", "label_sequence", "id", "date"],
112
+ data_url="https://dl.fbaipublicfiles.com/glue/SuperTweetEval/data/v2/BoolQ.zip",
113
+ ),
114
+ SuperTweetEvalConfig(
115
+ name="tweet_qa",
116
+ description=_TWEET_QA_DESCRIPTION,
117
+ citation=_TWEET_QA_CITATION,
118
+ features=["text", "label_str", "paragraph", "question"],
119
+ data_url="https://dl.fbaipublicfiles.com/glue/SuperTweetEval/data/v2/BoolQ.zip",
120
+ )
121
+ ]
122
+
123
+ def _info(self):
124
+ features = {feature: datasets.Value("string") for feature in self.config.features}
125
+ if self.config.name == "tweet_topic":
126
+ names = [
127
+ "arts_&_culture", "business_&_entrepreneurs", "celebrity_&_pop_culture", "diaries_&_daily_life",
128
+ "family", "fashion_&_style", "film_tv_&_video", "fitness_&_health", "food_&_dining", "gaming",
129
+ "learning_&_educational", "music", "news_&_social_concern", "other_hobbies", "relationships",
130
+ "science_&_technology", "sports", "travel_&_adventure", "youth_&_student_life"]
131
+ features["label_list"] = datasets.Sequence(datasets.features.ClassLabel(names=names))
132
+ if self.config.name == "tweet_ner7":
133
+ names = [
134
+ 'B-corporation', 'B-creative_work', 'B-event', 'B-group', 'B-location', 'B-person', 'B-product',
135
+ 'I-corporation', 'I-creative_work', 'I-event', 'I-group', 'I-location', 'I-person', 'I-product', 'O']
136
+ features["label_sequence"] = datasets.Sequence(datasets.features.ClassLabel(names=names))
137
+
138
+ return datasets.DatasetInfo(
139
+ description=_SUPER_TWEET_EVAL_DESCRIPTION + "\n" + self.config.description,
140
+ features=datasets.Features(features),
141
+ citation=self.config.citation + "\n" + _SUPER_TWEET_EVAL_CITATION,
142
+ )
143
+
144
+ def _split_generators(self, dl_manager):
145
+ dl_dir = dl_manager.download_and_extract(self.config.data_url) or ""
146
+ task_name = _get_task_name_from_data_url(self.config.data_url)
147
+ dl_dir = os.path.join(dl_dir, task_name)
148
+ if self.config.name in ["axb", "axg"]:
149
+ return [
150
+ datasets.SplitGenerator(
151
+ name=datasets.Split.TEST,
152
+ gen_kwargs={
153
+ "data_file": os.path.join(dl_dir, f"{task_name}.jsonl"),
154
+ "split": datasets.Split.TEST,
155
+ },
156
+ ),
157
+ ]
158
+ return [
159
+ datasets.SplitGenerator(
160
+ name=datasets.Split.TRAIN,
161
+ gen_kwargs={
162
+ "data_file": os.path.join(dl_dir, "train.jsonl"),
163
+ "split": datasets.Split.TRAIN,
164
+ },
165
+ ),
166
+ datasets.SplitGenerator(
167
+ name=datasets.Split.VALIDATION,
168
+ gen_kwargs={
169
+ "data_file": os.path.join(dl_dir, "val.jsonl"),
170
+ "split": datasets.Split.VALIDATION,
171
+ },
172
+ ),
173
+ datasets.SplitGenerator(
174
+ name=datasets.Split.TEST,
175
+ gen_kwargs={
176
+ "data_file": os.path.join(dl_dir, "test.jsonl"),
177
+ "split": datasets.Split.TEST,
178
+ },
179
+ ),
180
+ ]
181
+
182
+ def _generate_examples(self, data_file, split):
183
+ with open(data_file, encoding="utf-8") as f:
184
+ for line in f:
185
+ row = json.loads(line)
186
+
187
+ if self.config.name == "multirc":
188
+ paragraph = row["passage"]
189
+ for question in paragraph["questions"]:
190
+ for answer in question["answers"]:
191
+ label = answer.get("label")
192
+ key = "%s_%s_%s" % (row["idx"], question["idx"], answer["idx"])
193
+ yield key, {
194
+ "paragraph": paragraph["text"],
195
+ "question": question["question"],
196
+ "answer": answer["text"],
197
+ "label": -1 if label is None else _cast_label(bool(label)),
198
+ "idx": {"paragraph": row["idx"], "question": question["idx"], "answer": answer["idx"]},
199
+ }
200
+ elif self.config.name == "record":
201
+ passage = row["passage"]
202
+ entity_texts, entity_spans = _get_record_entities(passage)
203
+ for qa in row["qas"]:
204
+ yield qa["idx"], {
205
+ "passage": passage["text"],
206
+ "query": qa["query"],
207
+ "entities": entity_texts,
208
+ "entity_spans": entity_spans,
209
+ "answers": _get_record_answers(qa),
210
+ "idx": {"passage": row["idx"], "query": qa["idx"]},
211
+ }
212
+ else:
213
+ if self.config.name.startswith("wsc"):
214
+ row.update(row["target"])
215
+ example = {feature: row[feature] for feature in self.config.features}
216
+ if self.config.name == "wsc.fixed":
217
+ example = _fix_wst(example)
218
+ example["idx"] = row["idx"]
219
+
220
+ if "label" in row:
221
+ if self.config.name == "copa":
222
+ example["label"] = "choice2" if row["label"] else "choice1"
223
+ else:
224
+ example["label"] = _cast_label(row["label"])
225
+ else:
226
+ assert split == datasets.Split.TEST, row
227
+ example["label"] = -1
228
+ yield example["idx"], example