fernando-peres commited on
Commit
56180ce
·
1 Parent(s): cdd1980

adjustments

Browse files
Files changed (1) hide show
  1. py_legislation.py +18 -37
py_legislation.py CHANGED
@@ -248,28 +248,6 @@ class PYLegislation(datasets.GeneratorBasedBuilder):
248
 
249
  description = _CONFIGS["raw_text"]["description"]
250
 
251
- # if self.config.name == "raw_text":
252
- # description = _metadata["raw_text"]["description"]
253
-
254
- # features = datasets.Features(
255
- # _metadata["raw_text"]["features"]
256
- # )
257
-
258
- # if self.config.name == "unlabeled_sentences":
259
- # description = _metadata["unlabeled_sentences"]["description"]
260
- # features = datasets.Features(
261
- # _metadata["unlabeled_sentences"]["features"])
262
-
263
- # if self.config.name == "labeled_sentences":
264
- # description = _metadata["labeled_sentences"]["description"]
265
- # features = datasets.Features(
266
- # _metadata["labeled_sentences"]["features"])
267
-
268
- # else:
269
- # features = datasets.Features(
270
- # _metadata["raw_text"]["description"]
271
- # )
272
-
273
  return datasets.DatasetInfo(
274
  builder_name=self.config.name,
275
  description=description,
@@ -280,16 +258,19 @@ class PYLegislation(datasets.GeneratorBasedBuilder):
280
  )
281
 
282
  def _split_generators(self, dl_manager):
283
- # TODO: labeled subset has two splits
284
- # generators = []
285
-
286
- urls_to_download = _URLS[self.config.name]
287
- filepaths = dl_manager.download_and_extract(urls_to_download)
288
-
289
- return datasets.SplitGenerator(
290
- name=datasets.Split.TRAIN,
291
- gen_kwargs={"filepath": filepaths}
292
- )
 
 
 
293
 
294
  # region old code
295
  # for k in urls_to_download:
@@ -337,12 +318,12 @@ class PYLegislation(datasets.GeneratorBasedBuilder):
337
  The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
338
  Obs: method parameters are unpacked from `gen_kwargs` as given in `_split_generators`.
339
  """
340
- # Ensure that the filepath is an absolute local file path
341
- filepath = os.path.abspath(filepath)
342
 
343
- # Check if the file exists
344
- if not os.path.exists(filepath):
345
- raise FileNotFoundError(f"File not found: {filepath}")
346
 
347
  pq_table = pq.read_table(filepath)
348
  for i in range(len(pq_table)):
 
248
 
249
  description = _CONFIGS["raw_text"]["description"]
250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  return datasets.DatasetInfo(
252
  builder_name=self.config.name,
253
  description=description,
 
258
  )
259
 
260
  def _split_generators(self, dl_manager):
261
+ urls = _URLS[self.config.name]
262
+ # data_dir = dl_manager.download_and_extract(urls)
263
+ urls = dl_manager.download_and_extract(urls)
264
+
265
+ return [
266
+ datasets.SplitGenerator(
267
+ name=datasets.Split.TRAIN,
268
+ # These kwargs will be passed to _generate_examples
269
+ # gen_kwargs={"filepath": os.path.join(data_dir)},
270
+ # gen_kwargs={"filepath": os.path.join(urls)},
271
+ gen_kwargs={"filepath": urls},
272
+ ),
273
+ ]
274
 
275
  # region old code
276
  # for k in urls_to_download:
 
318
  The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
319
  Obs: method parameters are unpacked from `gen_kwargs` as given in `_split_generators`.
320
  """
321
+ # # Ensure that the filepath is an absolute local file path
322
+ # filepath = os.path.abspath(filepath)
323
 
324
+ # # Check if the file exists
325
+ # if not os.path.exists(filepath):
326
+ # raise FileNotFoundError(f"File not found: {filepath}")
327
 
328
  pq_table = pq.read_table(filepath)
329
  for i in range(len(pq_table)):