wnut2017 / wnut2017.py
asahi417's picture
""" NER dataset compiled by T-NER library https://github.com/asahi417/tner/tree/master/tner """
import json
from itertools import chain
import datasets
logger = datasets.logging.get_logger(__name__)
_DESCRIPTION = """[WNUT 2017 NER dataset](https://aclanthology.org/W17-4418/)"""
_NAME = "wnut2017"
_VERSION = "1.0.0"
title = "Results of the {WNUT}2017 Shared Task on Novel and Emerging Entity Recognition",
author = "Derczynski, Leon and
Nichols, Eric and
van Erp, Marieke and
Limsopatham, Nut",
booktitle = "Proceedings of the 3rd Workshop on Noisy User-generated Text",
month = sep,
year = "2017",
address = "Copenhagen, Denmark",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/W17-4418",
doi = "10.18653/v1/W17-4418",
pages = "140--147",
abstract = "This shared task focuses on identifying unusual, previously-unseen entities in the context of emerging discussions. Named entities form the basis of many modern approaches to other tasks (like event clustering and summarization), but recall on them is a real problem in noisy text - even among annotators. This drop tends to be due to novel entities and surface forms. Take for example the tweet {``}so.. kktny in 30 mins?!{''} {--} even human experts find the entity {`}kktny{'} hard to detect and resolve. The goal of this task is to provide a definition of emerging and of rare entities, and based on that, also datasets for detecting these entities. The task as described in this paper evaluated the ability of participating entries to detect and classify novel and emerging named entities in noisy text.",
_HOME_PAGE = "https://github.com/asahi417/tner"
_URL = f'https://huggingface.co/datasets/tner/{_NAME}/raw/main/dataset'
_URLS = {
str(datasets.Split.TEST): [f'{_URL}/test.json'],
str(datasets.Split.TRAIN): [f'{_URL}/train.json'],
str(datasets.Split.VALIDATION): [f'{_URL}/valid.json'],
class WNUT2017Config(datasets.BuilderConfig):
def __init__(self, **kwargs):
**kwargs: keyword arguments forwarded to super.
super(WNUT2017Config, self).__init__(**kwargs)
class WNUT2017(datasets.GeneratorBasedBuilder):
WNUT2017Config(name=_NAME, version=datasets.Version(_VERSION), description=_DESCRIPTION),
def _split_generators(self, dl_manager):
downloaded_file = dl_manager.download_and_extract(_URLS)
return [datasets.SplitGenerator(name=i, gen_kwargs={"filepaths": downloaded_file[str(i)]})
for i in [datasets.Split.TRAIN, datasets.Split.VALIDATION, datasets.Split.TEST]]
def _generate_examples(self, filepaths):
_key = 0
for filepath in filepaths:
logger.info(f"generating examples from = {filepath}")
with open(filepath, encoding="utf-8") as f:
_list = [i for i in f.read().split('\n') if len(i) > 0]
for i in _list:
data = json.loads(i)
yield _key, data
_key += 1
def _info(self):
return datasets.DatasetInfo(
"tokens": datasets.Sequence(datasets.Value("string")),
"tags": datasets.Sequence(datasets.Value("int32")),