Kevin Zhao commited on
Commit
e6ec423
1 Parent(s): 7a65d2a

Initial commit

Browse files
.gitattributes CHANGED
@@ -36,3 +36,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
36
  *.mp3 filter=lfs diff=lfs merge=lfs -text
37
  *.ogg filter=lfs diff=lfs merge=lfs -text
38
  *.wav filter=lfs diff=lfs merge=lfs -text
 
 
36
  *.mp3 filter=lfs diff=lfs merge=lfs -text
37
  *.ogg filter=lfs diff=lfs merge=lfs -text
38
  *.wav filter=lfs diff=lfs merge=lfs -text
39
+ *.csv filter=lfs diff=lfs merge=lfs -text
CPRAG/dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"CPRAG": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"context_s1": {"dtype": "string", "id": null, "_type": "Value"}, "context_s2": {"dtype": "string", "id": null, "_type": "Value"}, "expected": {"dtype": "string", "id": null, "_type": "Value"}, "within_category": {"dtype": "string", "id": null, "_type": "Value"}, "between_category": {"dtype": "string", "id": null, "_type": "Value"}, "constraint": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "csv", "config_name": "CPRAG", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 5372, "num_examples": 34, "dataset_name": "csv"}}, "download_checksums": {"/home/kzhao/Ettinger/CPRAG/test.csv": {"num_bytes": 4875, "checksum": "17e185c8abcc3b6ea0f28485e43334608cd50105c51f18e93ffa2d5d935b37a9"}}, "download_size": 4875, "post_processing_size": null, "dataset_size": 5372, "size_in_bytes": 10247}}
CPRAG/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:17e185c8abcc3b6ea0f28485e43334608cd50105c51f18e93ffa2d5d935b37a9
3
+ size 4875
Ettinger.py ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # TODO: Address all TODOs and remove all explanatory comments
15
+ """TODO: Add a description here."""
16
+
17
+
18
+ import datasets
19
+ import pandas as pd
20
+
21
+
22
+ # TODO: Add BibTeX citation
23
+ # Find for instance the citation on arxiv or on the dataset repo/website
24
+ _CITATION = """\
25
+ @InProceedings{huggingface:dataset,
26
+ title = {A great new dataset},
27
+ author={huggingface, Inc.
28
+ },
29
+ year={2020}
30
+ }
31
+ """
32
+
33
+ # TODO: Add description of the dataset here
34
+ # You can copy an official description
35
+ _DESCRIPTION = """\
36
+ This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
37
+ """
38
+
39
+ # TODO: Add a link to an official homepage for the dataset here
40
+ _HOMEPAGE = ""
41
+
42
+ # TODO: Add the licence for the dataset here if you can find it
43
+ _LICENSE = ""
44
+
45
+ # TODO: Add link to the official dataset URLs here
46
+ # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
47
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
48
+ _PATHS = {
49
+ "CPRAG": "CPRAG/test.csv",
50
+ "ROLE": "ROLE/test.csv",
51
+ "NEG-NAT": "NEG-NAT/test.csv",
52
+ "NEG-SIMP": "NEG-SIMP/test.csv",
53
+ }
54
+
55
+ # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
56
+ class NewDataset(datasets.GeneratorBasedBuilder):
57
+ """TODO: Short description of my dataset."""
58
+
59
+ VERSION = datasets.Version("1.0.0")
60
+
61
+ # This is an example of a dataset with multiple configurations.
62
+ # If you don't want/need to define several sub-sets in your dataset,
63
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
64
+
65
+ # If you need to make complex sub-parts in the datasets with configurable options
66
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
67
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
68
+
69
+ # You will be able to load one or the other configurations in the following list with
70
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
71
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
72
+ BUILDER_CONFIGS = [
73
+ datasets.BuilderConfig(name="CPRAG", version=VERSION, description="[CPRAG description]"),
74
+ datasets.BuilderConfig(name="ROLE", version=VERSION, description="[ROLE description]"),
75
+ datasets.BuilderConfig(name="NEG-NAT", version=VERSION, description="[NEG-NAT description]"),
76
+ datasets.BuilderConfig(name="NEG-SIMP", version=VERSION, description="[NEG-SIMP description]"),
77
+ ]
78
+
79
+ def _info(self):
80
+ # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
81
+ if self.config.name == "CPRAG": # This is the name of the configuration selected in BUILDER_CONFIGS above
82
+ features = datasets.Features(
83
+ {
84
+ "context_s1": datasets.Value("string"),
85
+ "context_s2": datasets.Value("string"),
86
+ "expected": datasets.Value("string"),
87
+ "within_category": datasets.Value("string"),
88
+ "between_category": datasets.Value("string"),
89
+ }
90
+ )
91
+ elif self.config.name == "ROLE":
92
+ features = datasets.Features(
93
+ {
94
+ "context": datasets.Value("string"),
95
+ "expected": datasets.Value("string"),
96
+ }
97
+ )
98
+ elif self.config.name == "NEG-NAT":
99
+ features = datasets.Features(
100
+ {
101
+ "context_aff": datasets.Value("string"),
102
+ "context_neg": datasets.Value("string"),
103
+ "target_aff": datasets.Value("string"),
104
+ "target_neg": datasets.Value("string"),
105
+ }
106
+ )
107
+ elif self.config.name == "NEG-SIMP":
108
+ features = datasets.Features(
109
+ {
110
+ "context_aff": datasets.Value("string"),
111
+ "context_neg": datasets.Value("string"),
112
+ "target_aff": datasets.Value("string"),
113
+ "target_neg": datasets.Value("string"),
114
+ }
115
+ )
116
+ else:
117
+ raise NotImplementedError
118
+
119
+ return datasets.DatasetInfo(
120
+ # This is the description that will appear on the datasets page.
121
+ description=_DESCRIPTION,
122
+ # This defines the different columns of the dataset and their types
123
+ features=features, # Here we define them above because they are different between the two configurations
124
+ # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
125
+ # specify them. They'll be used if as_supervised=True in builder.as_dataset.
126
+ # supervised_keys=("sentence", "label"),
127
+ # Homepage of the dataset for documentation
128
+ homepage=_HOMEPAGE,
129
+ # License for the dataset if available
130
+ license=_LICENSE,
131
+ # Citation for the dataset
132
+ citation=_CITATION,
133
+ )
134
+
135
+ def _split_generators(self, dl_manager):
136
+ # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
137
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
138
+
139
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
140
+ # 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.
141
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
142
+ return [
143
+ datasets.SplitGenerator(
144
+ name=datasets.Split.TEST,
145
+ # These kwargs will be passed to _generate_examples
146
+ gen_kwargs={
147
+ "filepath": _PATHS[self.config.name],
148
+ "split": "test"
149
+ },
150
+ ),
151
+ ]
152
+
153
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
154
+ def _generate_examples(self, filepath, split):
155
+ # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
156
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
157
+ df = pd.read_csv(filepath)
158
+ for index, row in df.iterrows():
159
+ if self.config.name == "NEG-NAT":
160
+ features = datasets.Features(
161
+ {
162
+ "context_aff": datasets.Value("string"),
163
+ "context_neg": datasets.Value("string"),
164
+ "target_aff": datasets.Value("string"),
165
+ "target_neg": datasets.Value("string"),
166
+ }
167
+ )
168
+ elif self.config.name == "NEG-SIMP":
169
+ features = datasets.Features(
170
+ {
171
+ "context_aff": datasets.Value("string"),
172
+ "context_neg": datasets.Value("string"),
173
+ "target_aff": datasets.Value("string"),
174
+ "target_neg": datasets.Value("string"),
175
+ }
176
+ )
177
+ if self.config.name == "CPRAG":
178
+ # Yields examples as (key, example) tuples
179
+ yield index, {
180
+ "context_s1": row["context_s1"],
181
+ "context_s2": row["context_s2"],
182
+ "expected": row["expected"],
183
+ "within_category": row["within_category"],
184
+ "between_category": row["between_category"],
185
+ }
186
+ elif self.config.name == "ROLE":
187
+ yield index, {
188
+ "context": row["context"],
189
+ "expected": row["expected"],
190
+ }
191
+ elif self.config.name == "NEG-NAT":
192
+ yield index, {
193
+ "context_aff": row["context_aff"],
194
+ "context_neg": row["context_neg"],
195
+ "target_aff": row["target_aff"],
196
+ "target_neg": row["target_neg"],
197
+ }
198
+ elif self.config.name == "NEG-SIMP":
199
+ yield index, {
200
+ "context_aff": row["context_aff"],
201
+ "context_neg": row["context_neg"],
202
+ "target_aff": row["target_aff"],
203
+ "target_neg": row["target_neg"],
204
+ }
205
+ else:
206
+ raise NotImplementedError
207
+
NEG-NAT/dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"CPRAG": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"context_s1": {"dtype": "string", "id": null, "_type": "Value"}, "context_s2": {"dtype": "string", "id": null, "_type": "Value"}, "expected": {"dtype": "string", "id": null, "_type": "Value"}, "within_category": {"dtype": "string", "id": null, "_type": "Value"}, "between_category": {"dtype": "string", "id": null, "_type": "Value"}, "constraint": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "csv", "config_name": "CPRAG", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 5372, "num_examples": 34, "dataset_name": "csv"}}, "download_checksums": {"/home/kzhao/Ettinger/CPRAG/test.csv": {"num_bytes": 4875, "checksum": "17e185c8abcc3b6ea0f28485e43334608cd50105c51f18e93ffa2d5d935b37a9"}}, "download_size": 4875, "post_processing_size": null, "dataset_size": 5372, "size_in_bytes": 10247}, "ROLE": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"context": {"dtype": "string", "id": null, "_type": "Value"}, "expected": {"dtype": "string", "id": null, "_type": "Value"}, "exp_cloze": {"dtype": "float64", "id": null, "_type": "Value"}, "target": {"dtype": "string", "id": null, "_type": "Value"}, "tgt_cloze": {"dtype": "float64", "id": null, "_type": "Value"}, "tgt_cloze(strict)": {"dtype": "float64", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "csv", "config_name": "ROLE", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 9350, "num_examples": 88, "dataset_name": "csv"}}, "download_checksums": {"/home/kzhao/Ettinger/ROLE/test.csv": {"num_bytes": 8668, "checksum": "6c23629624cb61044210439586f9fe4514f3baef2fa256f580e44cb981de0649"}}, "download_size": 8668, "post_processing_size": null, "dataset_size": 9350, "size_in_bytes": 18018}, "NEG-NAT": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"context_aff": {"dtype": "string", "id": null, "_type": "Value"}, "context_neg": {"dtype": "string", "id": null, "_type": "Value"}, "target_aff": {"dtype": "string", "id": null, "_type": "Value"}, "target_neg": {"dtype": "string", "id": null, "_type": "Value"}, "licensing": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "csv", "config_name": "NEG-NAT", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 1626, "num_examples": 16, "dataset_name": "csv"}}, "download_checksums": {"/home/kzhao/Ettinger/NEG-NAT/test.csv": {"num_bytes": 1450, "checksum": "5f3efad556ade6d624d612314e60b522d34ffd901a5911cdeb1f1563b6bb4e06"}}, "download_size": 1450, "post_processing_size": null, "dataset_size": 1626, "size_in_bytes": 3076}}
NEG-NAT/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f3efad556ade6d624d612314e60b522d34ffd901a5911cdeb1f1563b6bb4e06
3
+ size 1450
NEG-SIMP/dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"CPRAG": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"context_s1": {"dtype": "string", "id": null, "_type": "Value"}, "context_s2": {"dtype": "string", "id": null, "_type": "Value"}, "expected": {"dtype": "string", "id": null, "_type": "Value"}, "within_category": {"dtype": "string", "id": null, "_type": "Value"}, "between_category": {"dtype": "string", "id": null, "_type": "Value"}, "constraint": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "csv", "config_name": "CPRAG", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 5372, "num_examples": 34, "dataset_name": "csv"}}, "download_checksums": {"/home/kzhao/Ettinger/CPRAG/test.csv": {"num_bytes": 4875, "checksum": "17e185c8abcc3b6ea0f28485e43334608cd50105c51f18e93ffa2d5d935b37a9"}}, "download_size": 4875, "post_processing_size": null, "dataset_size": 5372, "size_in_bytes": 10247}, "ROLE": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"context": {"dtype": "string", "id": null, "_type": "Value"}, "expected": {"dtype": "string", "id": null, "_type": "Value"}, "exp_cloze": {"dtype": "float64", "id": null, "_type": "Value"}, "target": {"dtype": "string", "id": null, "_type": "Value"}, "tgt_cloze": {"dtype": "float64", "id": null, "_type": "Value"}, "tgt_cloze(strict)": {"dtype": "float64", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "csv", "config_name": "ROLE", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 9350, "num_examples": 88, "dataset_name": "csv"}}, "download_checksums": {"/home/kzhao/Ettinger/ROLE/test.csv": {"num_bytes": 8668, "checksum": "6c23629624cb61044210439586f9fe4514f3baef2fa256f580e44cb981de0649"}}, "download_size": 8668, "post_processing_size": null, "dataset_size": 9350, "size_in_bytes": 18018}, "NEG-NAT": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"context_aff": {"dtype": "string", "id": null, "_type": "Value"}, "context_neg": {"dtype": "string", "id": null, "_type": "Value"}, "target_aff": {"dtype": "string", "id": null, "_type": "Value"}, "target_neg": {"dtype": "string", "id": null, "_type": "Value"}, "licensing": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "csv", "config_name": "NEG-NAT", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 1626, "num_examples": 16, "dataset_name": "csv"}}, "download_checksums": {"/home/kzhao/Ettinger/NEG-NAT/test.csv": {"num_bytes": 1450, "checksum": "5f3efad556ade6d624d612314e60b522d34ffd901a5911cdeb1f1563b6bb4e06"}}, "download_size": 1450, "post_processing_size": null, "dataset_size": 1626, "size_in_bytes": 3076}, "NEG-SIMP": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"context_aff": {"dtype": "string", "id": null, "_type": "Value"}, "context_neg": {"dtype": "string", "id": null, "_type": "Value"}, "target_aff": {"dtype": "string", "id": null, "_type": "Value"}, "target_neg": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "csv", "config_name": "NEG-SIMP", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 1166, "num_examples": 18, "dataset_name": "csv"}}, "download_checksums": {"/home/kzhao/Ettinger/NEG-SIMP/test.csv": {"num_bytes": 996, "checksum": "b756a3d8c2bd4e919986e38b3e64f85b10aabc06c967b59eb098821a584dfc28"}}, "download_size": 996, "post_processing_size": null, "dataset_size": 1166, "size_in_bytes": 2162}}
NEG-SIMP/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b756a3d8c2bd4e919986e38b3e64f85b10aabc06c967b59eb098821a584dfc28
3
+ size 996
README.md CHANGED
@@ -1,3 +1,4 @@
1
  ---
2
  license: mit
3
  ---
 
 
1
  ---
2
  license: mit
3
  ---
4
+ Copyright (c) 2020 Allyson Ettinger
ROLE/dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"CPRAG": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"context_s1": {"dtype": "string", "id": null, "_type": "Value"}, "context_s2": {"dtype": "string", "id": null, "_type": "Value"}, "expected": {"dtype": "string", "id": null, "_type": "Value"}, "within_category": {"dtype": "string", "id": null, "_type": "Value"}, "between_category": {"dtype": "string", "id": null, "_type": "Value"}, "constraint": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "csv", "config_name": "CPRAG", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 5372, "num_examples": 34, "dataset_name": "csv"}}, "download_checksums": {"/home/kzhao/Ettinger/CPRAG/test.csv": {"num_bytes": 4875, "checksum": "17e185c8abcc3b6ea0f28485e43334608cd50105c51f18e93ffa2d5d935b37a9"}}, "download_size": 4875, "post_processing_size": null, "dataset_size": 5372, "size_in_bytes": 10247}, "ROLE": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"context": {"dtype": "string", "id": null, "_type": "Value"}, "expected": {"dtype": "string", "id": null, "_type": "Value"}, "exp_cloze": {"dtype": "float64", "id": null, "_type": "Value"}, "target": {"dtype": "string", "id": null, "_type": "Value"}, "tgt_cloze": {"dtype": "float64", "id": null, "_type": "Value"}, "tgt_cloze(strict)": {"dtype": "float64", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "csv", "config_name": "ROLE", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 9350, "num_examples": 88, "dataset_name": "csv"}}, "download_checksums": {"/home/kzhao/Ettinger/ROLE/test.csv": {"num_bytes": 8668, "checksum": "6c23629624cb61044210439586f9fe4514f3baef2fa256f580e44cb981de0649"}}, "download_size": 8668, "post_processing_size": null, "dataset_size": 9350, "size_in_bytes": 18018}}
ROLE/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c23629624cb61044210439586f9fe4514f3baef2fa256f580e44cb981de0649
3
+ size 8668