Datasets:

Modalities:
Tabular
Text
Languages:
English
ArXiv:
Libraries:
Datasets
License:
Kanishka Misra commited on
Commit
f25f5f1
·
1 Parent(s): a761557

added comps loading script

Browse files
Files changed (2) hide show
  1. README.md +17 -0
  2. comps.py +114 -0
README.md CHANGED
@@ -1,3 +1,20 @@
1
  ---
 
 
 
 
 
 
2
  license: apache-2.0
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
1
  ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - machine-generated
6
+ language:
7
+ - en
8
  license: apache-2.0
9
+ multilinguality:
10
+ - monolingual
11
+ pretty_name: COMPS
12
+ size_categories:
13
+ - 10K<n<100K
14
+ source_datasets:
15
+ - original
16
  ---
17
+
18
+ # Dataset Card for "blimp"
19
+
20
+ TBD
comps.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """COMPS: Conceptual Minimal Pair Sentences for analyzing property knowledge."""
18
+
19
+ import json
20
+
21
+ import datasets
22
+
23
+
24
+ _CITATION = """
25
+ @article{misra2022comps,
26
+ title={COMPS: Conceptual Minimal Pair Sentences for testing Property Knowledge and Inheritance in Pre-trained Language Models},
27
+ author={Misra, Kanishka and Rayz, Julia Taylor and Ettinger, Allyson},
28
+ journal={arXiv preprint arXiv:2210.01963},
29
+ year={2022}
30
+ }
31
+ """
32
+
33
+ _DESCRIPTION = """
34
+ COMPS is a dataset of minimal pair sentences in English that enables the
35
+ testing of the ability of language models to attribute properties to everyday
36
+ concepts, and also demonstrate property inheritance -- where subordinate
37
+ concepts inherit the properties of their superordinate (hypernyms).
38
+ """
39
+
40
+ _PROJECT_URL = "https://github.com/kanishkamisra/comps"
41
+ _DOWNLOAD_URL = "https://raw.githubusercontent.com/kanishkamisra/comps/main/" \
42
+ "data/comps/"
43
+
44
+
45
+ class CompsConfig(datasets.BuilderConfig):
46
+ """BuilderConfig for Blimp."""
47
+
48
+ def __init__(self, name, version=datasets.Version("0.1.0"), **kwargs):
49
+ """BuilderConfig for Blimp.
50
+
51
+ Args:
52
+ name (str): UID of the linguistic paradigm
53
+ **kwargs: keyword arguments forwarded to super.
54
+ """
55
+ description = _DESCRIPTION
56
+ if name == "base":
57
+ description += " This subset tests for base property knowledge."
58
+ elif name == "wugs":
59
+ description += " This subset tests for property inheritance" \
60
+ " without distraction."
61
+ else:
62
+ description += " This subset tests for property inheritance with" \
63
+ f" distraction ({name.replace('wugs-dist-')})."
64
+
65
+ super().__init__(name=name, description=description, version=version, **kwargs)
66
+
67
+
68
+ class Blimp(datasets.GeneratorBasedBuilder):
69
+ """Minimal grammatical and ungrammatical pairs of 67 linguistic paradigms."""
70
+
71
+ subsets = ("base", "wugs", "wugs_dist", "wugs_dist_before", "wugs_dist_in-between")
72
+
73
+ BUILDER_CONFIGS = [CompsConfig(subset) for subset in subsets]
74
+
75
+ def _info(self):
76
+ return datasets.DatasetInfo(
77
+ description=_DESCRIPTION,
78
+ features=datasets.Features(
79
+ {
80
+ "id": datasets.Value("int32"),
81
+ "property": datasets.Value("string"),
82
+ "acceptable_concept": datasets.Value("string"),
83
+ "unacceptable_concept": datasets.Value("string"),
84
+ "prefix_acceptable": datasets.Value("string"),
85
+ "prefix_unacceptable": datasets.Value("string"),
86
+ "property_phrase": datasets.Value("string"),
87
+ "negative_sample_type": datasets.Value("string"),
88
+ "similarity": datasets.Value("float32"),
89
+ "distraction_type": datasets.Value("string"),
90
+ }
91
+ ),
92
+ homepage=_PROJECT_URL,
93
+ citation=_CITATION,
94
+ )
95
+
96
+ def _split_generators(self, dl_manager):
97
+ """Returns SplitGenerators."""
98
+ download_urls = _DOWNLOAD_URL + f"comps_{self.config.name}.jsonl"
99
+ downloaded_file = dl_manager.download_and_extract(download_urls)
100
+ return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_file})]
101
+
102
+ def _generate_examples(self, filepath):
103
+ """Yields examples."""
104
+ with open(filepath, "r", encoding="utf-8") as f:
105
+ for line in f:
106
+ line_dict = json.loads(line)
107
+ if "wugs" in self.config.name:
108
+ id_ = line_dict["base_id"] + "_" + line_dict["distraction_type"]
109
+ else:
110
+ id_ = line_dict['id']
111
+ feats = {
112
+ **line_dict
113
+ }
114
+ yield id_, feats