patriziobellan commited on
Commit
984c4af
1 Parent(s): 3742211

Update PET.py

Browse files
Files changed (1) hide show
  1. PET.py +51 -36
PET.py CHANGED
@@ -76,14 +76,11 @@ _TEST_FILE_10 = "test.json"
76
  _TEST_FILE_RELATIONS_11 = "PETv1.1-relations.json"
77
  _TEST_FILE_RELATIONS_10 = 'PETrelations.json'
78
 
79
-
80
-
81
-
82
-
83
-
84
-
85
  _NER = 'token-classification'
 
86
  _RELATIONS_EXTRACTION = 'relations-extraction'
 
 
87
  _NER_TAGS = [ "O",
88
  "B-Actor",
89
  "I-Actor",
@@ -142,24 +139,24 @@ class PET(datasets.GeneratorBasedBuilder):
142
  ))
143
  BUILDER_CONFIGS = [ PETConfig(
144
  name=_NER,
145
- # version=datasets.Version("1.0.1"),
146
  description="The PET Dataset for Token Classification"
147
  ),
148
  PETConfig(
149
  name=_RELATIONS_EXTRACTION,
150
- # version=datasets.Version("1.0.1"),
 
 
 
 
 
 
 
 
 
 
151
  description="The PET Dataset for Relation Extraction"
152
  ),
153
- # PETConfig(
154
- # name=_NER,
155
- # version=datasets.Version("1.1.0"),
156
- # description="The PET Dataset for Token Classification"
157
- # ),
158
- # PETConfig(
159
- # name=_RELATIONS_EXTRACTION,
160
- # version=datasets.Version("1.1.0"),
161
- # description="The PET Dataset for Relation Extraction"
162
- # ),
163
  ]
164
 
165
  DEFAULT_CONFIG_NAME = _RELATIONS_EXTRACTION
@@ -189,16 +186,24 @@ class PET(datasets.GeneratorBasedBuilder):
189
  )
190
 
191
  def _split_generators(self, dl_manager):
192
- print(f"{self.config.version=}")
193
  if self.config.name == _NER:
194
- if self.config.version=='1.0.1':
195
- urls_to_download = {
196
- "test": f"{_URL_10}{_TEST_FILE_10}",
197
- }
198
- else:
199
- urls_to_download = {
200
- "test": f"{_URL_11}{_TEST_FILE_11}",
201
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
  downloaded_files = dl_manager.download_and_extract(urls_to_download)
204
  return [datasets.SplitGenerator(
@@ -209,24 +214,34 @@ class PET(datasets.GeneratorBasedBuilder):
209
  "split": "test"
210
  },
211
  )]
212
- else:
213
- if self.config.version=='1.0.1':
214
- urls_to_download = {
215
- "test": f"{_URL_10}{_TEST_FILE_RELATIONS_10}",
216
- }
217
- else:
218
- urls_to_download = {
219
- "test": f"{_URL_11}{_TEST_FILE_RELATIONS_11}",
220
  }
221
  downloaded_files = dl_manager.download_and_extract(urls_to_download)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  return [datasets.SplitGenerator(
223
  name=datasets.Split.TEST,
224
  # These kwargs will be passed to _generate_examples
225
  gen_kwargs={
226
  "filepath": downloaded_files["test"],
227
  "split": "test"
228
- },
229
- )]
230
 
231
  def _generate_examples(self, filepath, split):
232
  if self.config.name == _NER:
 
76
  _TEST_FILE_RELATIONS_11 = "PETv1.1-relations.json"
77
  _TEST_FILE_RELATIONS_10 = 'PETrelations.json'
78
 
 
 
 
 
 
 
79
  _NER = 'token-classification'
80
+ _NER_11 = 'token-classification-v1.1'
81
  _RELATIONS_EXTRACTION = 'relations-extraction'
82
+ _RELATIONS_EXTRACTION_11 = 'relations-extraction-v1.1'
83
+
84
  _NER_TAGS = [ "O",
85
  "B-Actor",
86
  "I-Actor",
 
139
  ))
140
  BUILDER_CONFIGS = [ PETConfig(
141
  name=_NER,
142
+ version=datasets.Version("1.0.1"),
143
  description="The PET Dataset for Token Classification"
144
  ),
145
  PETConfig(
146
  name=_RELATIONS_EXTRACTION,
147
+ version=datasets.Version("1.0.1"),
148
+ description="The PET Dataset for Relation Extraction"
149
+ ),
150
+ PETConfig(
151
+ name=_NER_11,
152
+ version=datasets.Version("1.1.0"),
153
+ description="The PET Dataset for Token Classification"
154
+ ),
155
+ PETConfig(
156
+ name=_RELATIONS_EXTRACTION_11,
157
+ version=datasets.Version("1.1.0"),
158
  description="The PET Dataset for Relation Extraction"
159
  ),
 
 
 
 
 
 
 
 
 
 
160
  ]
161
 
162
  DEFAULT_CONFIG_NAME = _RELATIONS_EXTRACTION
 
186
  )
187
 
188
  def _split_generators(self, dl_manager):
189
+ print(f"{self.config.version}")
190
  if self.config.name == _NER:
191
+ urls_to_download = {
192
+ "test": f"{_URL_10}{_TEST_FILE_10}",
 
 
 
 
 
193
  }
194
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
195
+ return [datasets.SplitGenerator(
196
+ name=datasets.Split.TEST,
197
+ # These kwargs will be passed to _generate_examples
198
+ gen_kwargs={
199
+ "filepath": downloaded_files["test"],
200
+ "split": "test"
201
+ },
202
+ )]
203
+ elif self.config.name == _NER_11:
204
+ urls_to_download = {
205
+ "test": f"{_URL_11}{_TEST_FILE_11}",
206
+ }
207
 
208
  downloaded_files = dl_manager.download_and_extract(urls_to_download)
209
  return [datasets.SplitGenerator(
 
214
  "split": "test"
215
  },
216
  )]
217
+
218
+ elif self.config.name == _RELATIONS_EXTRACTION:
219
+ urls_to_download = {
220
+ "test": f"{_URL_10}{_TEST_FILE_RELATIONS_10}",
 
 
 
 
221
  }
222
  downloaded_files = dl_manager.download_and_extract(urls_to_download)
223
+ return [datasets.SplitGenerator(
224
+ name=datasets.Split.TEST,
225
+ # These kwargs will be passed to _generate_examples
226
+ gen_kwargs={
227
+ "filepath": downloaded_files["test"],
228
+ "split": "test"
229
+ },
230
+ )]
231
+
232
+ else:
233
+ urls_to_download = {
234
+ "test": f"{_URL_11}{_TEST_FILE_RELATIONS_11}",
235
+ }
236
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
237
  return [datasets.SplitGenerator(
238
  name=datasets.Split.TEST,
239
  # These kwargs will be passed to _generate_examples
240
  gen_kwargs={
241
  "filepath": downloaded_files["test"],
242
  "split": "test"
243
+ },
244
+ )]
245
 
246
  def _generate_examples(self, filepath, split):
247
  if self.config.name == _NER: