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