Datasets:

Languages:
English
Multilinguality:
monolingual
Size Categories:
1K<n<10K
Language Creators:
machine-generated
Annotations Creators:
machine-generated
Source Datasets:
original
Tags:
License:
albertvillanova HF staff commited on
Commit
98a4184
1 Parent(s): 08c1003

Delete loading script

Browse files
Files changed (1) hide show
  1. imppres.py +0 -273
imppres.py DELETED
@@ -1,273 +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
- """Over 25k semiautomatically generated sentence pairs illustrating well-studied pragmatic inference types. IMPPRES is an NLI dataset following the format of SNLI (Bowman et al., 2015), MultiNLI (Williams et al., 2018) and XNLI (Conneau et al., 2018), which was created to evaluate how well trained NLI models recognize several classes of presuppositions and scalar implicatures."""
16
-
17
-
18
- import json
19
- import os
20
-
21
- import datasets
22
-
23
-
24
- # Find for instance the citation on arxiv or on the dataset repo/website
25
- _CITATION = """\
26
- @inproceedings{jeretic-etal-2020-natural,
27
- title = "Are Natural Language Inference Models {IMPPRESsive}? {L}earning {IMPlicature} and {PRESupposition}",
28
- author = "Jereti\v{c}, Paloma and
29
- Warstadt, Alex and
30
- Bhooshan, Suvrat and
31
- Williams, Adina",
32
- booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
33
- month = jul,
34
- year = "2020",
35
- address = "Online",
36
- publisher = "Association for Computational Linguistics",
37
- url = "https://www.aclweb.org/anthology/2020.acl-main.768",
38
- doi = "10.18653/v1/2020.acl-main.768",
39
- pages = "8690--8705",
40
- abstract = "Natural language inference (NLI) is an increasingly important task for natural language understanding, which requires one to infer whether a sentence entails another. However, the ability of NLI models to make pragmatic inferences remains understudied. We create an IMPlicature and PRESupposition diagnostic dataset (IMPPRES), consisting of 32K semi-automatically generated sentence pairs illustrating well-studied pragmatic inference types. We use IMPPRES to evaluate whether BERT, InferSent, and BOW NLI models trained on MultiNLI (Williams et al., 2018) learn to make pragmatic inferences. Although MultiNLI appears to contain very few pairs illustrating these inference types, we find that BERT learns to draw pragmatic inferences. It reliably treats scalar implicatures triggered by {``}some{''} as entailments. For some presupposition triggers like {``}only{''}, BERT reliably recognizes the presupposition as an entailment, even when the trigger is embedded under an entailment canceling operator like negation. BOW and InferSent show weaker evidence of pragmatic reasoning. We conclude that NLI training encourages models to learn some, but not all, pragmatic inferences.",
41
- }
42
- """
43
-
44
- # You can copy an official description
45
- _DESCRIPTION = """Over >25k semiautomatically generated sentence pairs illustrating well-studied pragmatic inference types. IMPPRES is an NLI dataset following the format of SNLI (Bowman et al., 2015), MultiNLI (Williams et al., 2018) and XNLI (Conneau et al., 2018), which was created to evaluate how well trained NLI models recognize several classes of presuppositions and scalar implicatures."""
46
- _HOMEPAGE = "https://github.com/facebookresearch/Imppres"
47
- _LICENSE = "Creative Commons Attribution-NonCommercial 4.0 International Public License"
48
-
49
- # The HuggingFace dataset library don't host the datasets but only point to the original files
50
- # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
51
- _URLs = {"default": "https://github.com/facebookresearch/Imppres/raw/main/dataset/IMPPRES.zip"}
52
-
53
-
54
- class Imppres(datasets.GeneratorBasedBuilder):
55
- """Each sentence type in IMPPRES is generated according to a template that specifies the linear order of the constituents in the sentence. The constituents are sampled from a vocabulary of over 3000 lexical items annotated with grammatical features needed to ensure wellformedness. We semiautomatically generate IMPPRES using a codebase developed by Warstadt et al. (2019a) and significantly expanded for the BLiMP dataset (Warstadt et al., 2019b)."""
56
-
57
- VERSION = datasets.Version("1.1.0")
58
-
59
- # This is an example of a dataset with multiple configurations.
60
- # If you don't want/need to define several sub-sets in your dataset,
61
- # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
62
-
63
- # If you need to make complex sub-parts in the datasets with configurable options
64
- # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
65
- # BUILDER_CONFIG_CLASS = MyBuilderConfig
66
-
67
- # You will be able to load one or the other configurations in the following list with
68
- # data = datasets.load_dataset('my_dataset', 'first_domain')
69
- # data = datasets.load_dataset('my_dataset', 'second_domain')
70
- BUILDER_CONFIGS = [
71
- datasets.BuilderConfig(
72
- name="presupposition_all_n_presupposition",
73
- version=VERSION,
74
- description="Presuppositions are facts that the speaker takes for granted when uttering a sentence.",
75
- ),
76
- datasets.BuilderConfig(
77
- name="presupposition_both_presupposition",
78
- version=VERSION,
79
- description="Presuppositions are facts that the speaker takes for granted when uttering a sentence.",
80
- ),
81
- datasets.BuilderConfig(
82
- name="presupposition_change_of_state",
83
- version=VERSION,
84
- description="Presuppositions are facts that the speaker takes for granted when uttering a sentence.",
85
- ),
86
- datasets.BuilderConfig(
87
- name="presupposition_cleft_existence",
88
- version=VERSION,
89
- description="Presuppositions are facts that the speaker takes for granted when uttering a sentence.",
90
- ),
91
- datasets.BuilderConfig(
92
- name="presupposition_cleft_uniqueness",
93
- version=VERSION,
94
- description="Presuppositions are facts that the speaker takes for granted when uttering a sentence.",
95
- ),
96
- datasets.BuilderConfig(
97
- name="presupposition_only_presupposition",
98
- version=VERSION,
99
- description="Presuppositions are facts that the speaker takes for granted when uttering a sentence.",
100
- ),
101
- datasets.BuilderConfig(
102
- name="presupposition_possessed_definites_existence",
103
- version=VERSION,
104
- description="Presuppositions are facts that the speaker takes for granted when uttering a sentence.",
105
- ),
106
- datasets.BuilderConfig(
107
- name="presupposition_possessed_definites_uniqueness",
108
- version=VERSION,
109
- description="Presuppositions are facts that the speaker takes for granted when uttering a sentence.",
110
- ),
111
- datasets.BuilderConfig(
112
- name="presupposition_question_presupposition",
113
- version=VERSION,
114
- description="Presuppositions are facts that the speaker takes for granted when uttering a sentence.",
115
- ),
116
- datasets.BuilderConfig(
117
- name="implicature_connectives",
118
- version=VERSION,
119
- description="Scalar implicatures are inferences which can be drawn when one member of a memorized lexical scale is uttered.",
120
- ),
121
- datasets.BuilderConfig(
122
- name="implicature_gradable_adjective",
123
- version=VERSION,
124
- description="Scalar implicatures are inferences which can be drawn when one member of a memorized lexical scale is uttered.",
125
- ),
126
- datasets.BuilderConfig(
127
- name="implicature_gradable_verb",
128
- version=VERSION,
129
- description="Scalar implicatures are inferences which can be drawn when one member of a memorized lexical scale is uttered.",
130
- ),
131
- datasets.BuilderConfig(
132
- name="implicature_modals",
133
- version=VERSION,
134
- description="Scalar implicatures are inferences which can be drawn when one member of a memorized lexical scale is uttered.",
135
- ),
136
- datasets.BuilderConfig(
137
- name="implicature_numerals_10_100",
138
- version=VERSION,
139
- description="Scalar implicatures are inferences which can be drawn when one member of a memorized lexical scale is uttered.",
140
- ),
141
- datasets.BuilderConfig(
142
- name="implicature_numerals_2_3",
143
- version=VERSION,
144
- description="Scalar implicatures are inferences which can be drawn when one member of a memorized lexical scale is uttered.",
145
- ),
146
- datasets.BuilderConfig(
147
- name="implicature_quantifiers",
148
- version=VERSION,
149
- description="Scalar implicatures are inferences which can be drawn when one member of a memorized lexical scale is uttered.",
150
- ),
151
- ]
152
-
153
- def _info(self):
154
- if (
155
- "presupposition" in self.config.name
156
- ): # This is the name of the configuration selected in BUILDER_CONFIGS above
157
- features = datasets.Features(
158
- {
159
- "premise": datasets.Value("string"),
160
- "hypothesis": datasets.Value("string"),
161
- "trigger": datasets.Value("string"),
162
- "trigger1": datasets.Value("string"),
163
- "trigger2": datasets.Value("string"),
164
- "presupposition": datasets.Value("string"),
165
- "gold_label": datasets.ClassLabel(names=["entailment", "neutral", "contradiction"]),
166
- "UID": datasets.Value("string"),
167
- "pairID": datasets.Value("string"),
168
- "paradigmID": datasets.Value("int16")
169
- # These are the features of your dataset like images, labels ...
170
- }
171
- )
172
- else: # This is an example to show how to have different features for "first_domain" and "second_domain"
173
- features = datasets.Features(
174
- {
175
- "premise": datasets.Value("string"),
176
- "hypothesis": datasets.Value("string"),
177
- "gold_label_log": datasets.ClassLabel(names=["entailment", "neutral", "contradiction"]),
178
- "gold_label_prag": datasets.ClassLabel(names=["entailment", "neutral", "contradiction"]),
179
- "spec_relation": datasets.Value("string"),
180
- "item_type": datasets.Value("string"),
181
- "trigger": datasets.Value("string"),
182
- "lexemes": datasets.Value("string"),
183
- # These are the features of your dataset like images, labels ...
184
- }
185
- )
186
- return datasets.DatasetInfo(
187
- # This is the description that will appear on the datasets page.
188
- description=_DESCRIPTION,
189
- # This defines the different columns of the dataset and their types
190
- features=features, # Here we define them above because they are different between the two configurations
191
- # If there's a common (input, target) tuple from the features,
192
- # specify them here. They'll be used if as_supervised=True in
193
- # builder.as_dataset.
194
- supervised_keys=None,
195
- # Homepage of the dataset for documentation
196
- homepage=_HOMEPAGE,
197
- # License for the dataset if available
198
- license=_LICENSE,
199
- # Citation for the dataset
200
- citation=_CITATION,
201
- )
202
-
203
- def _split_generators(self, dl_manager):
204
- """Returns SplitGenerators."""
205
- # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
206
- # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
207
-
208
- # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
209
- # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
210
- # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
211
- my_urls = _URLs["default"]
212
- base_config = self.config.name.split("_")[0]
213
- secondary_config = self.config.name.split(base_config + "_")[1]
214
- data_dir = os.path.join(dl_manager.download_and_extract(my_urls), "IMPPRES", base_config)
215
- return [
216
- datasets.SplitGenerator(
217
- name=secondary_config,
218
- # These kwargs will be passed to _generate_examples
219
- gen_kwargs={
220
- "filepath": os.path.join(data_dir, secondary_config + ".jsonl"),
221
- "split": "test",
222
- },
223
- )
224
- ]
225
-
226
- def _generate_examples(self, filepath, split):
227
- """Yields examples."""
228
- # TODO: This method will receive as arguments the `gen_kwargs` defined in the previous `_split_generators` method.
229
- # It is in charge of opening the given file and yielding (key, example) tuples from the dataset
230
- # The key is not important, it's more here for legacy reason (legacy from tfds)
231
-
232
- with open(filepath, encoding="utf-8") as f:
233
- for id_, row in enumerate(f):
234
- data = json.loads(row)
235
- if "presupposition" in self.config.name:
236
- if "trigger1" not in list(data.keys()):
237
- yield id_, {
238
- "premise": data["sentence1"],
239
- "hypothesis": data["sentence2"],
240
- "trigger": data["trigger"],
241
- "trigger1": "Not_In_Example",
242
- "trigger2": "Not_In_Example",
243
- "presupposition": data["presupposition"],
244
- "gold_label": data["gold_label"],
245
- "UID": data["UID"],
246
- "pairID": data["pairID"],
247
- "paradigmID": data["paradigmID"],
248
- }
249
- else:
250
- yield id_, {
251
- "premise": data["sentence1"],
252
- "hypothesis": data["sentence2"],
253
- "trigger": "Not_In_Example",
254
- "trigger1": data["trigger1"],
255
- "trigger2": data["trigger2"],
256
- "presupposition": "Not_In_Example",
257
- "gold_label": data["gold_label"],
258
- "UID": data["UID"],
259
- "pairID": data["pairID"],
260
- "paradigmID": data["paradigmID"],
261
- }
262
-
263
- else:
264
- yield id_, {
265
- "premise": data["sentence1"],
266
- "hypothesis": data["sentence2"],
267
- "gold_label_log": data["gold_label_log"],
268
- "gold_label_prag": data["gold_label_prag"],
269
- "spec_relation": data["spec_relation"],
270
- "item_type": data["item_type"],
271
- "trigger": data["trigger"],
272
- "lexemes": data["lexemes"],
273
- }