Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
English
Size:
10K - 100K
ArXiv:
License:
Delete loading script
Browse files- tweet_topic_multi.py +0 -102
tweet_topic_multi.py
DELETED
|
@@ -1,102 +0,0 @@
|
|
| 1 |
-
""" TweetTopic Dataset """
|
| 2 |
-
import json
|
| 3 |
-
from itertools import chain
|
| 4 |
-
import datasets
|
| 5 |
-
|
| 6 |
-
logger = datasets.logging.get_logger(__name__)
|
| 7 |
-
_DESCRIPTION = """[TweetTopic](https://arxiv.org/abs/2209.09824)"""
|
| 8 |
-
|
| 9 |
-
_VERSION = "1.0.4"
|
| 10 |
-
_CITATION = """
|
| 11 |
-
@inproceedings{dimosthenis-etal-2022-twitter,
|
| 12 |
-
title = "{T}witter {T}opic {C}lassification",
|
| 13 |
-
author = "Antypas, Dimosthenis and
|
| 14 |
-
Ushio, Asahi and
|
| 15 |
-
Camacho-Collados, Jose and
|
| 16 |
-
Neves, Leonardo and
|
| 17 |
-
Silva, Vitor and
|
| 18 |
-
Barbieri, Francesco",
|
| 19 |
-
booktitle = "Proceedings of the 29th International Conference on Computational Linguistics",
|
| 20 |
-
month = oct,
|
| 21 |
-
year = "2022",
|
| 22 |
-
address = "Gyeongju, Republic of Korea",
|
| 23 |
-
publisher = "International Committee on Computational Linguistics"
|
| 24 |
-
}
|
| 25 |
-
"""
|
| 26 |
-
_HOME_PAGE = "https://cardiffnlp.github.io"
|
| 27 |
-
_LABEL_TYPE = "multi"
|
| 28 |
-
_NAME = f"tweet_topic_{_LABEL_TYPE}"
|
| 29 |
-
_URL = f'https://huggingface.co/datasets/cardiffnlp/{_NAME}/raw/main/dataset'
|
| 30 |
-
_URLS = {
|
| 31 |
-
f"{str(datasets.Split.TEST)}_2020": [f'{_URL}/split_temporal/test_2020.{_LABEL_TYPE}.json'],
|
| 32 |
-
f"{str(datasets.Split.TEST)}_2021": [f'{_URL}/split_temporal/test_2021.{_LABEL_TYPE}.json'],
|
| 33 |
-
f"{str(datasets.Split.TRAIN)}_2020": [f'{_URL}/split_temporal/train_2020.{_LABEL_TYPE}.json'],
|
| 34 |
-
f"{str(datasets.Split.TRAIN)}_2021": [f'{_URL}/split_temporal/train_2021.{_LABEL_TYPE}.json'],
|
| 35 |
-
f"{str(datasets.Split.TRAIN)}_all": [f'{_URL}/split_temporal/train_2020.{_LABEL_TYPE}.json', f'{_URL}/split_temporal/train_2021.{_LABEL_TYPE}.json'],
|
| 36 |
-
f"{str(datasets.Split.VALIDATION)}_2020": [f'{_URL}/split_temporal/validation_2020.{_LABEL_TYPE}.json'],
|
| 37 |
-
f"{str(datasets.Split.VALIDATION)}_2021": [f'{_URL}/split_temporal/validation_2021.{_LABEL_TYPE}.json'],
|
| 38 |
-
f"{str(datasets.Split.TRAIN)}_random": [f'{_URL}/split_random/train_random.{_LABEL_TYPE}.json'],
|
| 39 |
-
f"{str(datasets.Split.VALIDATION)}_random": [f'{_URL}/split_random/validation_random.{_LABEL_TYPE}.json'],
|
| 40 |
-
f"{str(datasets.Split.TEST)}_coling2022_random": [f'{_URL}/split_coling2022_random/test_random.{_LABEL_TYPE}.json'],
|
| 41 |
-
f"{str(datasets.Split.TRAIN)}_coling2022_random": [f'{_URL}/split_coling2022_random/train_random.{_LABEL_TYPE}.json'],
|
| 42 |
-
f"{str(datasets.Split.TEST)}_coling2022": [f'{_URL}/split_coling2022_temporal/test_2021.{_LABEL_TYPE}.json'],
|
| 43 |
-
f"{str(datasets.Split.TRAIN)}_coling2022": [f'{_URL}/split_coling2022_temporal/train_2020.{_LABEL_TYPE}.json'],
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
class TweetTopicSingleConfig(datasets.BuilderConfig):
|
| 48 |
-
"""BuilderConfig"""
|
| 49 |
-
|
| 50 |
-
def __init__(self, **kwargs):
|
| 51 |
-
"""BuilderConfig.
|
| 52 |
-
|
| 53 |
-
Args:
|
| 54 |
-
**kwargs: keyword arguments forwarded to super.
|
| 55 |
-
"""
|
| 56 |
-
super(TweetTopicSingleConfig, self).__init__(**kwargs)
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
class TweetTopicSingle(datasets.GeneratorBasedBuilder):
|
| 60 |
-
"""Dataset."""
|
| 61 |
-
|
| 62 |
-
BUILDER_CONFIGS = [
|
| 63 |
-
TweetTopicSingleConfig(name=_NAME, version=datasets.Version(_VERSION), description=_DESCRIPTION),
|
| 64 |
-
]
|
| 65 |
-
|
| 66 |
-
def _split_generators(self, dl_manager):
|
| 67 |
-
downloaded_file = dl_manager.download_and_extract(_URLS)
|
| 68 |
-
return [datasets.SplitGenerator(name=i, gen_kwargs={"filepaths": downloaded_file[i]}) for i in _URLS.keys()]
|
| 69 |
-
|
| 70 |
-
def _generate_examples(self, filepaths):
|
| 71 |
-
_key = 0
|
| 72 |
-
for filepath in filepaths:
|
| 73 |
-
logger.info(f"generating examples from = {filepath}")
|
| 74 |
-
with open(filepath, encoding="utf-8") as f:
|
| 75 |
-
_list = [i for i in f.read().split('\n') if len(i) > 0]
|
| 76 |
-
for i in _list:
|
| 77 |
-
data = json.loads(i)
|
| 78 |
-
yield _key, data
|
| 79 |
-
_key += 1
|
| 80 |
-
|
| 81 |
-
def _info(self):
|
| 82 |
-
names = [
|
| 83 |
-
"arts_&_culture", "business_&_entrepreneurs", "celebrity_&_pop_culture", "diaries_&_daily_life", "family",
|
| 84 |
-
"fashion_&_style", "film_tv_&_video", "fitness_&_health", "food_&_dining", "gaming",
|
| 85 |
-
"learning_&_educational", "music", "news_&_social_concern", "other_hobbies", "relationships",
|
| 86 |
-
"science_&_technology", "sports", "travel_&_adventure", "youth_&_student_life"
|
| 87 |
-
]
|
| 88 |
-
return datasets.DatasetInfo(
|
| 89 |
-
description=_DESCRIPTION,
|
| 90 |
-
features=datasets.Features(
|
| 91 |
-
{
|
| 92 |
-
"text": datasets.Value("string"),
|
| 93 |
-
"date": datasets.Value("string"),
|
| 94 |
-
"label": datasets.Sequence(datasets.features.ClassLabel(names=names)),
|
| 95 |
-
"label_name": datasets.Sequence(datasets.Value("string")),
|
| 96 |
-
"id": datasets.Value("string")
|
| 97 |
-
}
|
| 98 |
-
),
|
| 99 |
-
supervised_keys=None,
|
| 100 |
-
homepage=_HOME_PAGE,
|
| 101 |
-
citation=_CITATION,
|
| 102 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|