albertvillanova HF staff commited on
Commit
638290f
1 Parent(s): 06b62ea

Delete loading script

Browse files
Files changed (1) hide show
  1. paws.py +0 -209
paws.py DELETED
@@ -1,209 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
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
- """PAWS, a dataset for paraphrase identification"""
16
-
17
-
18
- import csv
19
-
20
- import datasets
21
-
22
-
23
- _CITATION = """\
24
- @InProceedings{paws2019naacl,
25
- title = {{PAWS: Paraphrase Adversaries from Word Scrambling}},
26
- author = {Zhang, Yuan and Baldridge, Jason and He, Luheng},
27
- booktitle = {Proc. of NAACL},
28
- year = {2019}
29
- }
30
- """
31
-
32
- _DESCRIPTION = """\
33
- PAWS: Paraphrase Adversaries from Word Scrambling
34
-
35
- This dataset contains 108,463 human-labeled and 656k noisily labeled pairs that feature
36
- the importance of modeling structure, context, and word order information for the problem
37
- of paraphrase identification. The dataset has two subsets, one based on Wikipedia and the
38
- other one based on the Quora Question Pairs (QQP) dataset.
39
-
40
- For further details, see the accompanying paper: PAWS: Paraphrase Adversaries from Word Scrambling
41
- (https://arxiv.org/abs/1904.01130)
42
-
43
- PAWS-QQP is not available due to license of QQP. It must be reconstructed by downloading the original
44
- data and then running our scripts to produce the data and attach the labels.
45
-
46
- NOTE: There might be some missing or wrong labels in the dataset and we have replaced them with -1.
47
- """
48
-
49
- _HOMEPAGE = "https://github.com/google-research-datasets/paws"
50
-
51
- _LICENSE = 'The dataset may be freely used for any purpose, although acknowledgement of Google LLC ("Google") as the data source would be appreciated. The dataset is provided "AS IS" without any warranty, express or implied. Google disclaims all liability for any damages, direct or indirect, resulting from the use of the dataset.'
52
-
53
- _DATA_OPTIONS = [
54
- "labeled_final",
55
- "labeled_swap",
56
- "unlabeled_final",
57
- ]
58
-
59
-
60
- class PAWSConfig(datasets.BuilderConfig):
61
- """BuilderConfig for PAWS."""
62
-
63
- def __init__(self, **kwargs):
64
- """Constructs a PAWSConfig.
65
- Args:
66
- **kwargs: keyword arguments forwarded to super.
67
- """
68
- super(PAWSConfig, self).__init__(version=datasets.Version("1.1.0", ""), **kwargs),
69
-
70
-
71
- class PAWS(datasets.GeneratorBasedBuilder):
72
- """PAWS, a dataset for paraphrase identification"""
73
-
74
- VERSION = datasets.Version("1.1.0")
75
-
76
- BUILDER_CONFIGS = [
77
- PAWSConfig(
78
- name=config_name,
79
- description=(f"This config contains samples of {config_name}."),
80
- )
81
- for config_name in _DATA_OPTIONS
82
- ]
83
-
84
- def _info(self):
85
- features = datasets.Features(
86
- {
87
- "id": datasets.Value("int32"),
88
- "sentence1": datasets.Value("string"),
89
- "sentence2": datasets.Value("string"),
90
- "label": datasets.features.ClassLabel(names=["0", "1"]),
91
- }
92
- )
93
- return datasets.DatasetInfo(
94
- # This is the description that will appear on the datasets page.
95
- description=_DESCRIPTION,
96
- # This defines the different columns of the dataset and their types
97
- features=features, # Here we define them above because they are different between the two configurations
98
- # If there's a common (input, target) tuple from the features,
99
- # specify them here. They'll be used if as_supervised=True in
100
- # builder.as_dataset.
101
- supervised_keys=None,
102
- # Homepage of the dataset for documentation
103
- homepage=_HOMEPAGE,
104
- # License for the dataset if available
105
- license=_LICENSE,
106
- # Citation for the dataset
107
- citation=_CITATION,
108
- )
109
-
110
- def _split_generators(self, dl_manager):
111
- """Returns SplitGenerators."""
112
-
113
- _DATA_URL = f"https://storage.googleapis.com/paws/english/paws_wiki_{self.config.name}.tar.gz"
114
- archive = dl_manager.download(_DATA_URL)
115
-
116
- if self.config.name == "labeled_final":
117
- _TRAIN_FILE_NAME = "/".join(["final", "train.tsv"])
118
- _VAL_FILE_NAME = "/".join(["final", "dev.tsv"])
119
- _TEST_FILE_NAME = "/".join(["final", "test.tsv"])
120
- return [
121
- datasets.SplitGenerator(
122
- name=datasets.Split.TRAIN,
123
- # These kwargs will be passed to _generate_examples
124
- gen_kwargs={
125
- "filepath": _TRAIN_FILE_NAME,
126
- "files": dl_manager.iter_archive(archive),
127
- },
128
- ),
129
- datasets.SplitGenerator(
130
- name=datasets.Split.TEST,
131
- # These kwargs will be passed to _generate_examples
132
- gen_kwargs={
133
- "filepath": _TEST_FILE_NAME,
134
- "files": dl_manager.iter_archive(archive),
135
- },
136
- ),
137
- datasets.SplitGenerator(
138
- name=datasets.Split.VALIDATION,
139
- # These kwargs will be passed to _generate_examples
140
- gen_kwargs={
141
- "filepath": _VAL_FILE_NAME,
142
- "files": dl_manager.iter_archive(archive),
143
- },
144
- ),
145
- ]
146
-
147
- elif self.config.name == "labeled_swap":
148
- _TRAIN_FILE_NAME = "/".join(["swap", "train.tsv"])
149
- return [
150
- datasets.SplitGenerator(
151
- name=datasets.Split.TRAIN,
152
- # These kwargs will be passed to _generate_examples
153
- gen_kwargs={
154
- "filepath": _TRAIN_FILE_NAME,
155
- "files": dl_manager.iter_archive(archive),
156
- },
157
- ),
158
- ]
159
-
160
- elif self.config.name == "unlabeled_final":
161
- _TRAIN_FILE_NAME = "/".join(["unlabeled", "final", "train.tsv"])
162
- _VAL_FILE_NAME = "/".join(["unlabeled", "final", "dev.tsv"])
163
- return [
164
- datasets.SplitGenerator(
165
- name=datasets.Split.TRAIN,
166
- # These kwargs will be passed to _generate_examples
167
- gen_kwargs={
168
- "filepath": _TRAIN_FILE_NAME,
169
- "files": dl_manager.iter_archive(archive),
170
- },
171
- ),
172
- datasets.SplitGenerator(
173
- name=datasets.Split.VALIDATION,
174
- # These kwargs will be passed to _generate_examples
175
- gen_kwargs={
176
- "filepath": _VAL_FILE_NAME,
177
- "files": dl_manager.iter_archive(archive),
178
- },
179
- ),
180
- ]
181
- else:
182
- raise NotImplementedError(f"{self.config.name} does not exist")
183
-
184
- def _generate_examples(self, filepath, files):
185
- """Yields examples."""
186
- for path, f in files:
187
- if path == filepath:
188
- lines = (line.decode("utf-8") for line in f)
189
- data = csv.DictReader(lines, delimiter="\t")
190
- for id_, row in enumerate(data):
191
- if self.config.name != "unlabeled_final":
192
- if row["label"] not in ["0", "1"]:
193
- row["label"] = -1
194
- yield id_, {
195
- "id": row["id"],
196
- "sentence1": row["sentence1"],
197
- "sentence2": row["sentence2"],
198
- "label": row["label"],
199
- }
200
- else:
201
- if row["noisy_label"] not in ["0", "1"]:
202
- row["noisy_label"] = -1
203
- yield id_, {
204
- "id": row["id"],
205
- "sentence1": row["sentence1"],
206
- "sentence2": row["sentence2"],
207
- "label": row["noisy_label"],
208
- }
209
- break