|
|
|
|
|
import json |
|
import datasets |
|
|
|
|
|
_CITATION = """\ |
|
@misc{loureiro2021analysis, |
|
title={Analysis and Evaluation of Language Models for Word Sense Disambiguation}, |
|
author={Daniel Loureiro and Kiamehr Rezaee and Mohammad Taher Pilehvar and Jose Camacho-Collados}, |
|
year={2021}, |
|
eprint={2008.11608}, |
|
archivePrefix={arXiv}, |
|
primaryClass={cs.CL} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
The CoarseWSD-20 dataset is a coarse-grained sense disambiguation built from Wikipedia |
|
(nouns only) targetting 2 to 5 senses of 20 ambiguous words. It was specifically designed |
|
to provide an ideal setting for evaluating WSD models (e.g. no senses in test sets missing |
|
from training), both quantitavely and qualitatively. |
|
""" |
|
|
|
path = "/content/CoarseWSD-20/apple/train.data.txt" |
|
|
|
|
|
|
|
class CWSD20(datasets.GeneratorBasedBuilder): |
|
"""TODO(WiCTSV): Short description of my dataset.""" |
|
|
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
def _info(self): |
|
|
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=datasets.Features( |
|
{ |
|
"idx": datasets.Value("int32"), |
|
"sentence": datasets.Value("string"), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
), |
|
|
|
|
|
|
|
supervised_keys=None, |
|
|
|
homepage="https://github.com/google-research-datasets/boolean-questions", |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
|
|
|
|
|
|
|
|
dl = path |
|
|
|
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, |
|
gen_kwargs={"ex": dl})] |
|
|
|
def _generate_examples(self, ex): |
|
"""Yields examples.""" |
|
with open(ex, encoding="utf-8") as exf: |
|
for id_, exi in enumerate(exf): |
|
example = {} |
|
|
|
parts = exi.split("\t") |
|
idx = parts[0] |
|
sent = parts[1] |
|
example["sentence"] = sent |
|
example["idx"] = idx |
|
|
|
yield id_, example |