shriyaa44 commited on
Commit
6f7c1f6
·
verified ·
1 Parent(s): 9918257

Delete loading script

Browse files
Files changed (1) hide show
  1. scirepeval_test.py +0 -197
scirepeval_test.py DELETED
@@ -1,197 +0,0 @@
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 csv
19
- import json
20
- import os
21
- import glob
22
-
23
- import datasets
24
- from datasets.data_files import DataFilesDict
25
- from .scirepeval_test_configs import SCIREPEVAL_CONFIGS
26
- #from datasets.packaged_modules.json import json
27
-
28
-
29
- # TODO: Add BibTeX citation
30
- # Find for instance the citation on arxiv or on the dataset repo/website
31
- _CITATION = """\
32
- @InProceedings{huggingface:dataset,
33
- title = {A great new dataset},
34
- author={huggingface, Inc.
35
- },
36
- year={2021}
37
- }
38
- """
39
-
40
- # TODO: Add description of the dataset here
41
- # You can copy an official description
42
- _DESCRIPTION = """\
43
- This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
44
- """
45
-
46
- # TODO: Add a link to an official homepage for the dataset here
47
- _HOMEPAGE = ""
48
-
49
- # TODO: Add the licence for the dataset here if you can find it
50
- _LICENSE = ""
51
-
52
- # TODO: Add link to the official dataset URLs here
53
- # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
54
- # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
55
- _URLS = {
56
- "first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip",
57
- "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
58
- }
59
-
60
-
61
-
62
- # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
63
- class Scirepeval(datasets.GeneratorBasedBuilder):
64
- """TODO: Short description of my dataset."""
65
-
66
- VERSION = datasets.Version("1.1.0")
67
-
68
- # This is an example of a dataset with multiple configurations.
69
- # If you don't want/need to define several sub-sets in your dataset,
70
- # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
71
-
72
- # If you need to make complex sub-parts in the datasets with configurable options
73
- # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
74
- # BUILDER_CONFIG_CLASS = MyBuilderConfig
75
-
76
- # You will be able to load one or the other configurations in the following list with
77
- # data = datasets.load_dataset('my_dataset', 'first_domain')
78
- # data = datasets.load_dataset('my_dataset', 'second_domain')
79
- BUILDER_CONFIGS = SCIREPEVAL_CONFIGS
80
-
81
- def _info(self):
82
- return datasets.DatasetInfo(
83
- # This is the description that will appear on the datasets page.
84
- description=_DESCRIPTION,
85
- # This defines the different columns of the dataset and their types
86
- features=datasets.Features(self.config.features), # Here we define them above because they are different between the two configurations
87
- # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
88
- # specify them. They'll be used if as_supervised=True in builder.as_dataset.
89
- # supervised_keys=("sentence", "label"),
90
- # Homepage of the dataset for documentation
91
- homepage=_HOMEPAGE,
92
- # License for the dataset if available
93
- license=_LICENSE,
94
- # Citation for the dataset
95
- citation=_CITATION,
96
- )
97
-
98
- def _split_generators(self, dl_manager):
99
- # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
100
- # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
101
- base_url = "https://ai2-s2-research-public.s3.us-west-2.amazonaws.com/scirepeval"
102
- data_urls = dict()
103
- data_dir = self.config.url if self.config.url else self.config.name
104
-
105
- if self.config.task_type in set(["classification", "regression"]):
106
- data_urls.update({"train": f"{base_url}/test/{data_dir}/train.csv"})
107
- data_urls.update({"test": f"{base_url}/test/{data_dir}/test.csv"})
108
- elif self.config.task_type == "metadata":
109
- data_urls.update({"metadata": f"{base_url}/test/{data_dir}/reviewer_metadata.jsonl"})
110
- elif "reviewer_matching" in self.config.name:
111
- data_urls.update({"test_hard": f"{base_url}/test/{data_dir}/test_hard_qrel.jsonl",
112
- "test_soft": f"{base_url}/test/{data_dir}/test_soft_qrel.jsonl"})
113
- else:
114
- data_urls.update({"test": f"{base_url}/test/{data_dir}/test_qrel.jsonl"})
115
-
116
- downloaded_files = dl_manager.download_and_extract(data_urls)
117
- splits = []
118
- if self.config.task_type == "metadata":
119
- splits = [datasets.SplitGenerator(
120
- name=datasets.Split("metadata"),
121
- # These kwargs will be passed to _generate_examples
122
- gen_kwargs={
123
- "filepath": downloaded_files["metadata"],
124
- "split": "metadata"
125
- },
126
- ),
127
- ]
128
- elif "reviewer_matching" in self.config.name:
129
- splits = [datasets.SplitGenerator(
130
- name=datasets.Split("test_hard"),
131
- # These kwargs will be passed to _generate_examples
132
- gen_kwargs={
133
- "filepath": downloaded_files["test_hard"],
134
- "split": "test"
135
- },
136
- ),
137
- datasets.SplitGenerator(
138
- name=datasets.Split("test_soft"),
139
- # These kwargs will be passed to _generate_examples
140
- gen_kwargs={
141
- "filepath": downloaded_files["test_soft"],
142
- "split": "test"
143
- },
144
- )
145
- ]
146
- else:
147
- splits = [datasets.SplitGenerator(
148
- name=datasets.Split.TEST,
149
- # These kwargs will be passed to _generate_examples
150
- gen_kwargs={
151
- "filepath": downloaded_files["test"],
152
- "split": "test"
153
- },
154
- ),
155
- ]
156
-
157
- if "train" in downloaded_files:
158
- splits += [
159
- datasets.SplitGenerator(
160
- name=datasets.Split.TRAIN,
161
- # These kwargs will be passed to _generate_examples
162
- gen_kwargs={
163
- "filepath": downloaded_files["train"],
164
- "split": "train",
165
- },
166
- )]
167
- return splits
168
-
169
-
170
- # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
171
- def _generate_examples(self, filepath, split):
172
- # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
173
- # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
174
- # data = read_data(filepath)
175
- if self.config.task_type in set(["classification", "regression"]):
176
- import csv
177
- import ast
178
- with open(filepath, encoding="utf-8") as f:
179
- reader = csv.reader(f)
180
- for id_, row in enumerate(reader):
181
- if id_ == 0:
182
- continue
183
- yield id_, {
184
- "paper_id": row[0],
185
- "label": ast.literal_eval(",".join(row[1:])) if self.config.name=="fos" else row[1]
186
- }
187
- elif self.config.task_type == "metadata":
188
- with open(filepath, encoding="utf-8") as f:
189
- for line in f:
190
- d = json.loads(line)
191
- yield d["r_id"], d
192
- else:
193
- with open(filepath, encoding="utf-8") as f:
194
- for i, line in enumerate(f):
195
- d = json.loads(line)
196
- yield i, d
197
-