Datasets:
Tasks:
Token Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
word-sense-disambiguation
Languages:
English
Size:
1K - 10K
License:
File size: 4,292 Bytes
00ea102 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# coding=utf-8
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Lint as: python3
"""The Definite Pronoun Resolution Dataset."""
from __future__ import absolute_import, division, print_function
import datasets
_CITATION = """\
@inproceedings{rahman2012resolving,
title={Resolving complex cases of definite pronouns: the winograd schema challenge},
author={Rahman, Altaf and Ng, Vincent},
booktitle={Proceedings of the 2012 Joint Conference on Empirical Methods in Natural Language Processing and Computational Natural Language Learning},
pages={777--789},
year={2012},
organization={Association for Computational Linguistics}
}"""
_DESCRIPTION = """\
Composed by 30 students from one of the author's undergraduate classes. These
sentence pairs cover topics ranging from real events (e.g., Iran's plan to
attack the Saudi ambassador to the U.S.) to events/characters in movies (e.g.,
Batman) and purely imaginary situations, largely reflecting the pop culture as
perceived by the American kids born in the early 90s. Each annotated example
spans four lines: the first line contains the sentence, the second line contains
the target pronoun, the third line contains the two candidate antecedents, and
the fourth line contains the correct antecedent. If the target pronoun appears
more than once in the sentence, its first occurrence is the one to be resolved.
"""
_DATA_URL_PATTERN = "http://www.hlt.utdallas.edu/~vince/data/emnlp12/{}.c.txt"
class DefinitePronounResolution(datasets.GeneratorBasedBuilder):
"""The Definite Pronoun Resolution Dataset."""
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="plain_text",
version=datasets.Version("1.0.0", ""),
description="Plain text import of the Definite Pronoun Resolution Dataset.", # pylint: disable=line-too-long
)
]
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"sentence": datasets.Value("string"),
"pronoun": datasets.Value("string"),
"candidates": datasets.features.Sequence(datasets.Value("string"), length=2),
"label": datasets.features.ClassLabel(num_classes=2),
}
),
supervised_keys=("sentence", "label"),
homepage="http://www.hlt.utdallas.edu/~vince/data/emnlp12/",
citation=_CITATION,
)
def _split_generators(self, dl_manager):
files = dl_manager.download_and_extract(
{
"train": _DATA_URL_PATTERN.format("train"),
"test": _DATA_URL_PATTERN.format("test"),
}
)
return [
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": files["test"]}),
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": files["train"]}),
]
def _generate_examples(self, filepath):
with open(filepath, encoding="utf-8") as f:
line_num = -1
while True:
line_num += 1
sentence = f.readline().strip()
pronoun = f.readline().strip()
candidates = [c.strip() for c in f.readline().strip().split(",")]
correct = f.readline().strip()
f.readline()
if not sentence:
break
yield line_num, {
"sentence": sentence,
"pronoun": pronoun,
"candidates": candidates,
"label": candidates.index(correct),
}
|