|
"""STAN large dataset"""
|
|
|
|
import datasets
|
|
import pandas as pd
|
|
import pickle5 as pickle
|
|
|
|
_CITATION = """
|
|
@inproceedings{maddela-etal-2019-multi,
|
|
title = "Multi-task Pairwise Neural Ranking for Hashtag Segmentation",
|
|
author = "Maddela, Mounica and
|
|
Xu, Wei and
|
|
Preo{\c{t}}iuc-Pietro, Daniel",
|
|
booktitle = "Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics",
|
|
month = jul,
|
|
year = "2019",
|
|
address = "Florence, Italy",
|
|
publisher = "Association for Computational Linguistics",
|
|
url = "https://aclanthology.org/P19-1242",
|
|
doi = "10.18653/v1/P19-1242",
|
|
pages = "2538--2549",
|
|
abstract = "Hashtags are often employed on social media and beyond to add metadata to a textual utterance with the goal of increasing discoverability, aiding search, or providing additional semantics. However, the semantic content of hashtags is not straightforward to infer as these represent ad-hoc conventions which frequently include multiple words joined together and can include abbreviations and unorthodox spellings. We build a dataset of 12,594 hashtags split into individual segments and propose a set of approaches for hashtag segmentation by framing it as a pairwise ranking problem between candidate segmentations. Our novel neural approaches demonstrate 24.6{\%} error reduction in hashtag segmentation accuracy compared to the current state-of-the-art method. Finally, we demonstrate that a deeper understanding of hashtag semantics obtained through segmentation is useful for downstream applications such as sentiment analysis, for which we achieved a 2.6{\%} increase in average recall on the SemEval 2017 sentiment analysis dataset.",
|
|
}
|
|
"""
|
|
|
|
_DESCRIPTION = """
|
|
The description below was taken from the paper "Multi-task Pairwise Neural Ranking for Hashtag Segmentation"
|
|
by Maddela et al..
|
|
|
|
"STAN large, our new expert curated dataset, which includes all 12,594 unique English hashtags and their
|
|
associated tweets from the same Stanford dataset.
|
|
|
|
STAN small is the most commonly used dataset in previous work. However, after reexamination, we found annotation
|
|
errors in 6.8% of the hashtags in this dataset, which is significant given that the error rate of the state-of-the art
|
|
models is only around 10%. Most of the errors were related to named entities. For example, #lionhead,
|
|
which refers to the “Lionhead” video game company, was labeled as “lion head”.
|
|
|
|
We therefore constructed the STAN large dataset of 12,594 hashtags with additional quality control for human annotations."
|
|
"""
|
|
_URLS = {
|
|
"train": "https://github.com/prashantkodali/HashSet/raw/master/datasets/stan-large-maddela_et_al_train.pkl",
|
|
"dev": "https://github.com/prashantkodali/HashSet/raw/master/datasets/stan-large-maddela_et_al_dev.pkl",
|
|
"test": "https://github.com/prashantkodali/HashSet/raw/master/datasets/stan-large-maddela_et_al_test.pkl"
|
|
}
|
|
|
|
class StanLarge(datasets.GeneratorBasedBuilder):
|
|
|
|
VERSION = datasets.Version("1.0.0")
|
|
|
|
def _info(self):
|
|
return datasets.DatasetInfo(
|
|
description=_DESCRIPTION,
|
|
features=datasets.Features(
|
|
{
|
|
"index": datasets.Value("int32"),
|
|
"hashtag": datasets.Value("string"),
|
|
"segmentation": datasets.Value("string"),
|
|
"alternatives": datasets.Sequence(
|
|
{
|
|
"segmentation": datasets.Value("string")
|
|
}
|
|
)
|
|
}
|
|
),
|
|
supervised_keys=None,
|
|
homepage="https://github.com/mounicam/hashtag_master",
|
|
citation=_CITATION,
|
|
)
|
|
|
|
def _split_generators(self, dl_manager):
|
|
downloaded_files = dl_manager.download(_URLS)
|
|
return [
|
|
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"] }),
|
|
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"] }),
|
|
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"] }),
|
|
]
|
|
|
|
def _generate_examples(self, filepath):
|
|
|
|
def get_segmentation(row):
|
|
return row["goldtruths"][0]
|
|
|
|
def get_alternatives(row):
|
|
segmentations = [{
|
|
"segmentation": x
|
|
} for x in row["goldtruths"]]
|
|
|
|
return segmentations[1:]
|
|
|
|
with open(filepath, 'rb') as f:
|
|
records = pickle.load(f)
|
|
records = records.to_dict("records")
|
|
for idx, row in enumerate(records):
|
|
yield idx, {
|
|
"index": idx,
|
|
"hashtag": row["hashtags"],
|
|
"segmentation": get_segmentation(row),
|
|
"alternatives": get_alternatives(row)
|
|
}
|
|
|