Kevin Zhao
commited on
Commit
·
8304308
1
Parent(s):
e6ec423
Changed to download csv instead of loading local file
Browse files- Ettinger.py +40 -31
- dataset_infos.json +1 -0
Ettinger.py
CHANGED
@@ -22,11 +22,14 @@ import pandas as pd
|
|
22 |
# TODO: Add BibTeX citation
|
23 |
# Find for instance the citation on arxiv or on the dataset repo/website
|
24 |
_CITATION = """\
|
25 |
-
@
|
26 |
-
title
|
27 |
-
author={
|
28 |
-
},
|
29 |
-
|
|
|
|
|
|
|
30 |
}
|
31 |
"""
|
32 |
|
@@ -40,16 +43,38 @@ This new dataset is designed to solve this great NLP task and is crafted with a
|
|
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 |
-
|
49 |
-
|
50 |
-
"
|
51 |
-
"
|
52 |
-
"NEG-
|
|
|
53 |
}
|
54 |
|
55 |
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
@@ -139,12 +164,15 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
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":
|
148 |
"split": "test"
|
149 |
},
|
150 |
),
|
@@ -152,28 +180,9 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
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, {
|
|
|
22 |
# TODO: Add BibTeX citation
|
23 |
# Find for instance the citation on arxiv or on the dataset repo/website
|
24 |
_CITATION = """\
|
25 |
+
@article{ettinger2020bert,
|
26 |
+
title={What BERT is not: Lessons from a new suite of psycholinguistic diagnostics for language models},
|
27 |
+
author={Ettinger, Allyson},
|
28 |
+
journal={Transactions of the Association for Computational Linguistics},
|
29 |
+
volume={8},
|
30 |
+
pages={34--48},
|
31 |
+
year={2020},
|
32 |
+
publisher={MIT Press}
|
33 |
}
|
34 |
"""
|
35 |
|
|
|
43 |
_HOMEPAGE = ""
|
44 |
|
45 |
# TODO: Add the licence for the dataset here if you can find it
|
46 |
+
_LICENSE = """MIT License
|
47 |
+
|
48 |
+
Copyright (c) 2020 Allyson Ettinger
|
49 |
+
|
50 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
51 |
+
of this software and associated documentation files (the "Software"), to deal
|
52 |
+
in the Software without restriction, including without limitation the rights
|
53 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
54 |
+
copies of the Software, and to permit persons to whom the Software is
|
55 |
+
furnished to do so, subject to the following conditions:
|
56 |
+
|
57 |
+
The above copyright notice and this permission notice shall be included in all
|
58 |
+
copies or substantial portions of the Software.
|
59 |
+
|
60 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
61 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
62 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
63 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
64 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
65 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
66 |
+
SOFTWARE.
|
67 |
+
"""
|
68 |
|
69 |
# TODO: Add link to the official dataset URLs here
|
70 |
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
71 |
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
72 |
+
_URL = "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/"
|
73 |
+
_URLS = {
|
74 |
+
"CPRAG": _URL + "CPRAG/test.csv",
|
75 |
+
"ROLE": _URL + "ROLE/test.csv",
|
76 |
+
"NEG-NAT": _URL + "NEG-NAT/test.csv",
|
77 |
+
"NEG-SIMP": _URL + "NEG-SIMP/test.csv",
|
78 |
}
|
79 |
|
80 |
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
|
|
164 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
165 |
# 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.
|
166 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
167 |
+
|
168 |
+
downloaded_files = dl_manager.download_and_extract(_URLS)
|
169 |
+
|
170 |
return [
|
171 |
datasets.SplitGenerator(
|
172 |
name=datasets.Split.TEST,
|
173 |
# These kwargs will be passed to _generate_examples
|
174 |
gen_kwargs={
|
175 |
+
"filepath": downloaded_files[self.config.name],
|
176 |
"split": "test"
|
177 |
},
|
178 |
),
|
|
|
180 |
|
181 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
182 |
def _generate_examples(self, filepath, split):
|
|
|
183 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
184 |
df = pd.read_csv(filepath)
|
185 |
for index, row in df.iterrows():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
if self.config.name == "CPRAG":
|
187 |
# Yields examples as (key, example) tuples
|
188 |
yield index, {
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"CPRAG": {"description": "This new dataset is designed to solve this great NLP task and is crafted with a lot of care.\n", "citation": "@article{ettinger2020bert,\n title={What BERT is not: Lessons from a new suite of psycholinguistic diagnostics for language models},\n author={Ettinger, Allyson},\n journal={Transactions of the Association for Computational Linguistics},\n volume={8},\n pages={34--48},\n year={2020},\n publisher={MIT Press}\n}\n", "homepage": "", "license": "MIT License\n\nCopyright (c) 2020 Allyson Ettinger\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", "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"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "new_dataset", "config_name": "CPRAG", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 5202, "num_examples": 34, "dataset_name": "new_dataset"}}, "download_checksums": {"https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/CPRAG/test.csv": {"num_bytes": 4875, "checksum": "17e185c8abcc3b6ea0f28485e43334608cd50105c51f18e93ffa2d5d935b37a9"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/ROLE/test.csv": {"num_bytes": 8668, "checksum": "6c23629624cb61044210439586f9fe4514f3baef2fa256f580e44cb981de0649"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/NEG-NAT/test.csv": {"num_bytes": 1450, "checksum": "5f3efad556ade6d624d612314e60b522d34ffd901a5911cdeb1f1563b6bb4e06"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/NEG-SIMP/test.csv": {"num_bytes": 996, "checksum": "b756a3d8c2bd4e919986e38b3e64f85b10aabc06c967b59eb098821a584dfc28"}}, "download_size": 15989, "post_processing_size": null, "dataset_size": 5202, "size_in_bytes": 21191}, "ROLE": {"description": "This new dataset is designed to solve this great NLP task and is crafted with a lot of care.\n", "citation": "@article{ettinger2020bert,\n title={What BERT is not: Lessons from a new suite of psycholinguistic diagnostics for language models},\n author={Ettinger, Allyson},\n journal={Transactions of the Association for Computational Linguistics},\n volume={8},\n pages={34--48},\n year={2020},\n publisher={MIT Press}\n}\n", "homepage": "", "license": "MIT License\n\nCopyright (c) 2020 Allyson Ettinger\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", "features": {"context": {"dtype": "string", "id": null, "_type": "Value"}, "expected": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "new_dataset", "config_name": "ROLE", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 6290, "num_examples": 88, "dataset_name": "new_dataset"}}, "download_checksums": {"https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/CPRAG/test.csv": {"num_bytes": 4875, "checksum": "17e185c8abcc3b6ea0f28485e43334608cd50105c51f18e93ffa2d5d935b37a9"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/ROLE/test.csv": {"num_bytes": 8668, "checksum": "6c23629624cb61044210439586f9fe4514f3baef2fa256f580e44cb981de0649"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/NEG-NAT/test.csv": {"num_bytes": 1450, "checksum": "5f3efad556ade6d624d612314e60b522d34ffd901a5911cdeb1f1563b6bb4e06"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/NEG-SIMP/test.csv": {"num_bytes": 996, "checksum": "b756a3d8c2bd4e919986e38b3e64f85b10aabc06c967b59eb098821a584dfc28"}}, "download_size": 15989, "post_processing_size": null, "dataset_size": 6290, "size_in_bytes": 22279}, "NEG-NAT": {"description": "This new dataset is designed to solve this great NLP task and is crafted with a lot of care.\n", "citation": "@article{ettinger2020bert,\n title={What BERT is not: Lessons from a new suite of psycholinguistic diagnostics for language models},\n author={Ettinger, Allyson},\n journal={Transactions of the Association for Computational Linguistics},\n volume={8},\n pages={34--48},\n year={2020},\n publisher={MIT Press}\n}\n", "homepage": "", "license": "MIT License\n\nCopyright (c) 2020 Allyson Ettinger\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", "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": "new_dataset", "config_name": "NEG-NAT", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 1546, "num_examples": 16, "dataset_name": "new_dataset"}}, "download_checksums": {"https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/CPRAG/test.csv": {"num_bytes": 4875, "checksum": "17e185c8abcc3b6ea0f28485e43334608cd50105c51f18e93ffa2d5d935b37a9"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/ROLE/test.csv": {"num_bytes": 8668, "checksum": "6c23629624cb61044210439586f9fe4514f3baef2fa256f580e44cb981de0649"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/NEG-NAT/test.csv": {"num_bytes": 1450, "checksum": "5f3efad556ade6d624d612314e60b522d34ffd901a5911cdeb1f1563b6bb4e06"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/NEG-SIMP/test.csv": {"num_bytes": 996, "checksum": "b756a3d8c2bd4e919986e38b3e64f85b10aabc06c967b59eb098821a584dfc28"}}, "download_size": 15989, "post_processing_size": null, "dataset_size": 1546, "size_in_bytes": 17535}, "NEG-SIMP": {"description": "This new dataset is designed to solve this great NLP task and is crafted with a lot of care.\n", "citation": "@article{ettinger2020bert,\n title={What BERT is not: Lessons from a new suite of psycholinguistic diagnostics for language models},\n author={Ettinger, Allyson},\n journal={Transactions of the Association for Computational Linguistics},\n volume={8},\n pages={34--48},\n year={2020},\n publisher={MIT Press}\n}\n", "homepage": "", "license": "MIT License\n\nCopyright (c) 2020 Allyson Ettinger\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", "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": "new_dataset", "config_name": "NEG-SIMP", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 1166, "num_examples": 18, "dataset_name": "new_dataset"}}, "download_checksums": {"https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/CPRAG/test.csv": {"num_bytes": 4875, "checksum": "17e185c8abcc3b6ea0f28485e43334608cd50105c51f18e93ffa2d5d935b37a9"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/ROLE/test.csv": {"num_bytes": 8668, "checksum": "6c23629624cb61044210439586f9fe4514f3baef2fa256f580e44cb981de0649"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/NEG-NAT/test.csv": {"num_bytes": 1450, "checksum": "5f3efad556ade6d624d612314e60b522d34ffd901a5911cdeb1f1563b6bb4e06"}, "https://huggingface.co/datasets/KevinZ/Ettinger/resolve/main/NEG-SIMP/test.csv": {"num_bytes": 996, "checksum": "b756a3d8c2bd4e919986e38b3e64f85b10aabc06c967b59eb098821a584dfc28"}}, "download_size": 15989, "post_processing_size": null, "dataset_size": 1166, "size_in_bytes": 17155}}
|