asahi417 commited on
Commit
db30823
1 Parent(s): f1949f7
.gitignore CHANGED
@@ -1,2 +1,3 @@
1
  super_tweeteval
2
- data
 
 
1
  super_tweeteval
2
+ data
3
+ dataset/tweets/*.jsonline
dataset/ner/test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/ner/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/ner/validation.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/qa/test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/qa/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/qa/validation.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/topic/test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/topic/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/topic/validation.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/topic_ner/test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/topic_ner/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset/topic_ner/validation.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
timelm_preprocessor.py → misc/timelm_preprocessor.py RENAMED
File without changes
verified_users.v091122.txt → misc/verified_users.v091122.txt RENAMED
File without changes
process/tweet_corpus.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 2018: 10,732,804
3
+ 2019: 9,725,094
4
+ 2020: 31,449,608
5
+ 2021: 37,282,461
6
+ 2022: 74,024,575
7
+ """
8
+ import json
9
+ import os
10
+
11
+ files = [
12
+ "dataset/tweets/2018.jsonline",
13
+ "dataset/tweets/2019.jsonline",
14
+ "dataset/tweets/2020.jsonline",
15
+ "dataset/tweets/2021.jsonline",
16
+ "dataset/tweets/2022.jsonline"
17
+ ]
18
+ n_shard = 10000
19
+ root_dir = "dataset/tweets_sharded"
20
+
21
+ os.makedirs(root_dir, exist_ok=True)
22
+ counter = 0
23
+ file_id = 0
24
+ f_writer = open(f"{root_dir}/{file_id}.jsonl")
25
+ for i in files:
26
+ with open(i) as f:
27
+ for line in f:
28
+ tmp = json.loads(line)
29
+ tmp = {"id": tmp["id"], "text": tmp["text"], "date": tmp["created_at"]}
30
+ f_writer.write(json.dumps(tmp) + '\n')
31
+ counter += 1
32
+ if counter > n_shard:
33
+ file_id += 1
34
+ counter = 0
35
+ f_writer.close()
36
+ f_writer = open(f"{root_dir}/{file_id}.jsonl")
37
+
process/tweet_ner.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ from typing import List
4
+ from datasets import load_dataset
5
+
6
+ label2id = {
7
+ "B-corporation": 0,
8
+ "B-creative_work": 1,
9
+ "B-event": 2,
10
+ "B-group": 3,
11
+ "B-location": 4,
12
+ "B-person": 5,
13
+ "B-product": 6,
14
+ "I-corporation": 7,
15
+ "I-creative_work": 8,
16
+ "I-event": 9,
17
+ "I-group": 10,
18
+ "I-location": 11,
19
+ "I-person": 12,
20
+ "I-product": 13,
21
+ "O": 14
22
+ }
23
+ id2label = {v: k for k, v in label2id.items()}
24
+
25
+
26
+ def decode_ner_tags(tag_sequence: List, input_sequence: List):
27
+ """ decode ner tag sequence """
28
+
29
+ def update_collection(_tmp_entity, _tmp_entity_type, _tmp_pos, _out):
30
+ if len(_tmp_entity) != 0 and _tmp_entity_type is not None:
31
+ _out.append({'type': _tmp_entity_type, 'entity': _tmp_entity, 'position': _tmp_pos})
32
+ _tmp_entity = []
33
+ _tmp_entity_type = None
34
+ return _tmp_entity, _tmp_entity_type, _tmp_pos, _out
35
+
36
+ assert len(tag_sequence) == len(input_sequence), str([len(tag_sequence), len(input_sequence)])
37
+ out = []
38
+ tmp_entity = []
39
+ tmp_pos = []
40
+ tmp_entity_type = None
41
+ for n, (_l, _i) in enumerate(zip(tag_sequence, input_sequence)):
42
+ _l = id2label[_l]
43
+ if _l.startswith('B-'):
44
+ _, _, _, out = update_collection(tmp_entity, tmp_entity_type, tmp_pos, out)
45
+ tmp_entity_type = '-'.join(_l.split('-')[1:])
46
+ tmp_entity = [_i]
47
+ tmp_pos = [n]
48
+ elif _l.startswith('I-'):
49
+ tmp_tmp_entity_type = '-'.join(_l.split('-')[1:])
50
+ if len(tmp_entity) == 0:
51
+ # if 'I' not start with 'B', skip it
52
+ tmp_entity, tmp_entity_type, tmp_pos, out = update_collection(tmp_entity, tmp_entity_type, tmp_pos, out)
53
+ elif tmp_tmp_entity_type != tmp_entity_type:
54
+ # if the type does not match with the B, skip
55
+ tmp_entity, tmp_entity_type, tmp_pos, out = update_collection(tmp_entity, tmp_entity_type, tmp_pos, out)
56
+ else:
57
+ tmp_entity.append(_i)
58
+ tmp_pos.append(n)
59
+ elif _l == 'O':
60
+ tmp_entity, tmp_entity_type, tmp_pos, out = update_collection(tmp_entity, tmp_entity_type, tmp_pos, out)
61
+ else:
62
+ raise ValueError('unknown tag: {}'.format(_l))
63
+ _, _, _, out = update_collection(tmp_entity, tmp_entity_type, tmp_pos, out)
64
+ return out
65
+
66
+ data = load_dataset("tner/tweetner7")
67
+
68
+
69
+ def process(tmp):
70
+ tmp = [i.to_dict() for _, i in tmp.iterrows()]
71
+ for i in tmp:
72
+ tokens = ["@" + t.replace("{@", "").replace("@}", "").replace(" ", "_") if t.startswith("{@") else t
73
+ for t in i.pop('tokens')]
74
+ entities = []
75
+ for e in decode_ner_tags(i.pop('tags').tolist(), tokens):
76
+ entities.append(f'{" ".join(e["entity"])} ({e["type"]})')
77
+ i['text'] = " ".join(tokens).replace("{{USERNAME}}", "@user").replace("{{URL}}", "{URL}")
78
+ i['condition'] = f'Entities: {", ".join(entities)}'
79
+ return tmp
80
+
81
+
82
+ train = process(data["train_2020"].to_pandas())
83
+ train += process(data["train_2021"].to_pandas())
84
+ val = process(data["validation_2020"].to_pandas())
85
+ val += process(data["validation_2021"].to_pandas())
86
+ test = process(data["test_2021"].to_pandas())
87
+ os.makedirs("dataset/ner", exist_ok=True)
88
+ with open("dataset/ner/train.jsonl", "w") as f:
89
+ f.write("\n".join([json.dumps(i) for i in train]))
90
+ with open("dataset/ner/validation.jsonl", "w") as f:
91
+ f.write("\n".join([json.dumps(i) for i in val]))
92
+ with open("dataset/ner/test.jsonl", "w") as f:
93
+ f.write("\n".join([json.dumps(i) for i in test]))
94
+
95
+
96
+
process/tweet_qa.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ from datasets import load_dataset
4
+
5
+ data = load_dataset("lmqg/qg_tweetqa")
6
+
7
+
8
+ def process(tmp):
9
+ tmp = [i.to_dict() for _, i in tmp.iterrows()]
10
+ for i in tmp:
11
+ i.pop('paragraph_question')
12
+ i.pop('question')
13
+ i['text'] = i.pop("paragraph")
14
+ i['condition'] = f'Keyword: {i.pop("answer")}'
15
+ tmp = [i for i in tmp if 'http' not in i['text']]
16
+ return tmp
17
+
18
+
19
+ train = process(data["train"].to_pandas())
20
+ val = process(data["validation"].to_pandas())
21
+ test = process(data["test"].to_pandas())
22
+ os.makedirs("dataset/qa", exist_ok=True)
23
+ with open("dataset/qa/train.jsonl", "w") as f:
24
+ f.write("\n".join([json.dumps(i) for i in train]))
25
+ with open("dataset/qa/validation.jsonl", "w") as f:
26
+ f.write("\n".join([json.dumps(i) for i in val]))
27
+ with open("dataset/qa/test.jsonl", "w") as f:
28
+ f.write("\n".join([json.dumps(i) for i in test]))
29
+
30
+
31
+
process/tweet_topic.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import re
4
+ from datasets import load_dataset
5
+
6
+ os.makedirs("data/tweet_topic", exist_ok=True)
7
+ data = load_dataset("cardiffnlp/tweet_topic_multi")
8
+ re_user = re.compile(r'{@[^@^}]*@}')
9
+
10
+
11
+ def process(tmp):
12
+ tmp = [i.to_dict() for _, i in tmp.iterrows()]
13
+ for i in tmp:
14
+ i.pop("label")
15
+ text = i['text']
16
+ users = re_user.findall(text)
17
+ for u in users:
18
+ text = text.replace(u, u.replace("{@", "@").replace("@}", "").replace(" ", "_"))
19
+ text = text.replace("{{USERNAME}}", "@user").replace("{{URL}}", "{URL}")
20
+ i['text'] = text
21
+ i['condition'] = f'Topics: {", ".join([x.replace("_", " ") for x in i.pop("label_name")])}'
22
+ return tmp
23
+
24
+ train = process(data["train_2020"].to_pandas())
25
+ train += process(data["train_2021"].to_pandas())
26
+ val = process(data["validation_2020"].to_pandas())
27
+ val += process(data["validation_2021"].to_pandas())
28
+ test = process(data["test_2021"].to_pandas())
29
+ os.makedirs("dataset/topic", exist_ok=True)
30
+ with open("dataset/topic/train.jsonl", "w") as f:
31
+ f.write("\n".join([json.dumps(i) for i in train]))
32
+ with open("dataset/topic/validation.jsonl", "w") as f:
33
+ f.write("\n".join([json.dumps(i) for i in val]))
34
+ with open("dataset/topic/test.jsonl", "w") as f:
35
+ f.write("\n".join([json.dumps(i) for i in test]))
36
+
37
+
38
+
process/tweet_topic_ner.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import pandas as pd
3
+ import os
4
+
5
+ os.makedirs("dataset/topic_ner", exist_ok=True)
6
+ for s in ["test.jsonl", "train.jsonl", "validation.jsonl"]:
7
+ with open(f"dataset/topic/{s}") as f:
8
+ topic = pd.DataFrame([json.loads(i) for i in f.read().split("\n") if len(i) > 0])
9
+ with open(f"dataset/ner/{s}") as f:
10
+ ner = pd.DataFrame([json.loads(i) for i in f.read().split("\n") if len(i) > 0])
11
+ topic.index = topic.pop("id")
12
+ ner.index = ner.pop("id")
13
+ df_merge = pd.merge(topic, ner, left_index=True, right_index=True)
14
+ df_merge['text'] = df_merge.pop("text_x")
15
+ df_merge['date'] = df_merge.pop("date_x")
16
+ df_merge.pop("text_y")
17
+ df_merge.pop("date_y")
18
+ df_merge['condition'] = df_merge.pop("condition_x") + " \n" + df_merge.pop("condition_y")
19
+ with open(f"dataset/topic_ner/{s}", "w") as f:
20
+ f.write("\n".join([json.dumps(i) for i in df_merge.T.to_dict().values()]))
process_unlabeled_tweet.py DELETED
File without changes
tweet_generation.py CHANGED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tweet Generation Dataset."""
2
+ import json
3
+ import datasets
4
+
5
+ _VERSION = "0.0.0"
6
+ _TWEET_GENERATION_DESCRIPTION = """"""
7
+ _TWEET_GENERATION_CITATION = """"""
8
+
9
+ _TWEET_CORPUS_DESCRIPTION = """Unlabeled tweet corpus ranging from 2018 to 2022."""
10
+ _TWEET_CORPUS_CITATION = """\
11
+ @inproceedings{loureiro-etal-2022-timelms,
12
+ title = "{T}ime{LM}s: Diachronic Language Models from {T}witter",
13
+ author = "Loureiro, Daniel and
14
+ Barbieri, Francesco and
15
+ Neves, Leonardo and
16
+ Espinosa Anke, Luis and
17
+ Camacho-collados, Jose",
18
+ editor = "Basile, Valerio and
19
+ Kozareva, Zornitsa and
20
+ Stajner, Sanja",
21
+ booktitle = "Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics: System Demonstrations",
22
+ month = may,
23
+ year = "2022",
24
+ address = "Dublin, Ireland",
25
+ publisher = "Association for Computational Linguistics",
26
+ url = "https://aclanthology.org/2022.acl-demo.25",
27
+ doi = "10.18653/v1/2022.acl-demo.25",
28
+ pages = "251--260",
29
+ abstract = "Despite its importance, the time variable has been largely neglected in the NLP and language model literature. In this paper, we present TimeLMs, a set of language models specialized on diachronic Twitter data. We show that a continual learning strategy contributes to enhancing Twitter-based language models{'} capacity to deal with future and out-of-distribution tweets, while making them competitive with standardized and more monolithic benchmarks. We also perform a number of qualitative analyses showing how they cope with trends and peaks in activity involving specific named entities or concept drift. TimeLMs is available at github.com/cardiffnlp/timelms.",
30
+ }
31
+ """
32
+ _TWEET_TOPIC_DESCRIPTION = """
33
+ TweetTopic is a multi-label twitter topic classification task, where each example consists of a tweet
34
+ and a set of topics. One tweet can be associated with multiple topics, and the training/validation tweets are taken
35
+ from September 2019 to August 2020, while the test tweets are taken from September 2020 to August 2021.
36
+ Following the original work, we evaluate with macro F1 score."""
37
+ _TWEET_TOPIC_CITATION = """\
38
+ @inproceedings{antypas-etal-2022-twitter,
39
+ title = "{T}witter Topic Classification",
40
+ author = "Antypas, Dimosthenis and
41
+ Ushio, Asahi and
42
+ Camacho-Collados, Jose and
43
+ Silva, Vitor and
44
+ Neves, Leonardo and
45
+ Barbieri, Francesco",
46
+ booktitle = "Proceedings of the 29th International Conference on Computational Linguistics",
47
+ month = oct,
48
+ year = "2022",
49
+ address = "Gyeongju, Republic of Korea",
50
+ publisher = "International Committee on Computational Linguistics",
51
+ url = "https://aclanthology.org/2022.coling-1.299",
52
+ pages = "3386--3400",
53
+ 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.",
54
+ }
55
+ """
56
+ _TWEET_NER7_DESCRIPTION = """
57
+ TweetNER is a named-entity recognition dataset on Twitter. The training/validation tweets are taken
58
+ from September 2019 to August 2020, while the test tweets are taken from September 2020 to August 2021.
59
+ Following the original work, we evaluate with span F1 score.
60
+ """
61
+ _TWEET_NER7_CITATION = """\
62
+ @inproceedings{ushio-etal-2022-named,
63
+ title = "Named Entity Recognition in {T}witter: A Dataset and Analysis on Short-Term Temporal Shifts",
64
+ author = "Ushio, Asahi and
65
+ Barbieri, Francesco and
66
+ Sousa, Vitor and
67
+ Neves, Leonardo and
68
+ Camacho-Collados, Jose",
69
+ 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)",
70
+ month = nov,
71
+ year = "2022",
72
+ address = "Online only",
73
+ publisher = "Association for Computational Linguistics",
74
+ url = "https://aclanthology.org/2022.aacl-main.25",
75
+ pages = "309--319",
76
+ 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).",
77
+ }
78
+ """
79
+ _TWEET_NERD_DESCRIPTION = """TBA"""
80
+ _TWEET_NERD_CITATION = """\
81
+ @article{mishra2022tweetnerd,
82
+ title={TweetNERD--End to End Entity Linking Benchmark for Tweets},
83
+ author={Mishra, Shubhanshu and Saini, Aman and Makki, Raheleh and Mehta, Sneha and Haghighi, Aria and Mollahosseini, Ali},
84
+ journal={arXiv preprint arXiv:2210.08129},
85
+ year={2022}
86
+ }
87
+ """
88
+ _TWEET_SENTIMENT_DESCRIPTION = """TBA"""
89
+ _TWEET_SENTIMENT_CITATION = """\
90
+ TBA
91
+ """
92
+ _ROOT_URL = "https://huggingface.co/datasets/cardiffnlp/tweet_generation/resolve/main/dataset"
93
+
94
+
95
+ class TweetGenerationConfig(datasets.BuilderConfig):
96
+ """BuilderConfig for TweetGeneration."""
97
+
98
+ def __init__(self, features, data_url, citation, label_classes=("False", "True"), **kwargs):
99
+ """BuilderConfig for TweetGeneration.
100
+
101
+ Args:
102
+ features: `list[string]`, list of the features that will appear in the
103
+ feature dict. Should not include "label".
104
+ data_url: `string`, url to download the zip file from.
105
+ citation: `string`, citation for the data set.
106
+ url: `string`, url for information about the data set.
107
+ label_classes: `list[string]`, the list of classes for the label if the
108
+ label is present as a string. Non-string labels will be cast to either
109
+ "False" or "True".
110
+ **kwargs: keyword arguments forwarded to super.
111
+ """
112
+ super(TweetGenerationConfig, self).__init__(version=datasets.Version(_VERSION), **kwargs)
113
+ self.features = features
114
+ self.label_classes = label_classes
115
+ self.data_url = data_url
116
+ self.citation = citation
117
+
118
+
119
+ class TweetGeneration(datasets.GeneratorBasedBuilder):
120
+ """The TweetGeneration benchmark."""
121
+
122
+ BUILDER_CONFIGS = [
123
+ TweetGenerationConfig(
124
+ name="tweet_corpus",
125
+ description=_TWEET_CORPUS_DESCRIPTION,
126
+ citation=_TWEET_CORPUS_CITATION,
127
+ features=["id", "text", "date"],
128
+ data_url=f"{_ROOT_URL}/tweet",
129
+ )
130
+ ]
131
+
132
+ def _info(self):
133
+ features = {feature: datasets.Value("string") for feature in self.config.features}
134
+ if "topic" in self.config.name:
135
+ names = [
136
+ "arts_&_culture", "business_&_entrepreneurs", "celebrity_&_pop_culture", "diaries_&_daily_life",
137
+ "family", "fashion_&_style", "film_tv_&_video", "fitness_&_health", "food_&_dining", "gaming",
138
+ "learning_&_educational", "music", "news_&_social_concern", "other_hobbies", "relationships",
139
+ "science_&_technology", "sports", "travel_&_adventure", "youth_&_student_life"]
140
+ features["gold_label_list"] = datasets.Sequence(
141
+ datasets.features.ClassLabel(names=names))
142
+ elif "sentiment" in self.config.name:
143
+ features["text"] = datasets.Value("string")
144
+ features["gold_label_binary"] = datasets.Value("int32")
145
+ features["date"] = datasets.Value("string")
146
+ elif "nerd" in self.config.name:
147
+ features["target"] = datasets.Value("string")
148
+ features["text"] = datasets.Value("string")
149
+ features["definition"] = datasets.Value("string")
150
+ features["text_start"] = datasets.Value("int32")
151
+ features["text_end"] = datasets.Value("int32")
152
+ features["gold_label_binary"] = datasets.Value("int32")
153
+ features["date"] = datasets.Value("string")
154
+ elif "ner" in self.config.name:
155
+ names = [
156
+ "B-corporation", "B-creative_work", "B-event", "B-group", "B-location", "B-person", "B-product",
157
+ "I-corporation", "I-creative_work", "I-event", "I-group", "I-location", "I-person", "I-product", "O"]
158
+ features["gold_label_sequence"] = datasets.Sequence(datasets.features.ClassLabel(names=names))
159
+ features["text_tokenized"] = datasets.Sequence(datasets.Value("string"))
160
+ features["entities"] = datasets.features.Sequence(
161
+ {"entity": datasets.Value("string"), "type": datasets.Value("string")}
162
+ )
163
+ return datasets.DatasetInfo(
164
+ description=_TWEET_GENERATION_DESCRIPTION + "\n" + self.config.description,
165
+ features=datasets.Features(features),
166
+ citation=self.config.citation + "\n" + _TWEET_GENERATION_CITATION,
167
+ )
168
+
169
+ def _split_generators(self, dl_manager):
170
+ splits = ["train", "test", "validation"]
171
+ if "temporal" in self.config.name:
172
+ splits += ["test_1", "test_2", "test_3", "test_4"]
173
+ downloaded_file = dl_manager.download_and_extract(
174
+ {s: f"{self.config.data_url}/{s}.jsonl" for s in splits})
175
+ return [datasets.SplitGenerator(name=s, gen_kwargs={"filepath": downloaded_file[s]}) for s in splits]
176
+
177
+ def _generate_examples(self, filepath):
178
+ _key = 0
179
+ with open(filepath, encoding="utf-8") as f:
180
+ _list = [i for i in f.read().split("\n") if len(i) > 0]
181
+ for i in _list:
182
+ data = json.loads(i)
183
+ yield _key, data
184
+ _key += 1
util.py DELETED
@@ -1,13 +0,0 @@
1
- import re
2
-
3
-
4
- URL_RE = re.compile(r"https?:\/\/[\w\.\/\?\=\d&#%_:/-]+")
5
- HANDLE_RE = re.compile(r"@\w+")
6
- with open("verified_users.v091122.txt") as f:
7
- USER = set(i for i in f.read().split("\n") if len(i))
8
-
9
- def process_url(text: str) -> str:
10
- return URL_RE.sub("{URL}", text)
11
-
12
- def process_username(text: str) -> str:
13
- return HANDLE_RE.sub("[URL]", text)