graelo commited on
Commit
dc28465
1 Parent(s): 25a8d0a

feat: use ArrowBasedBuilder

Browse files
Files changed (1) hide show
  1. wikipedia.py +6 -13
wikipedia.py CHANGED
@@ -419,7 +419,7 @@ class WikipediaConfig(datasets.BuilderConfig):
419
  _DATE = "20230601"
420
 
421
 
422
- class Wikipedia(datasets.GeneratorBasedBuilder):
423
  """Wikipedia dataset."""
424
 
425
  # Use mirror (your.org) to avoid download caps.
@@ -465,19 +465,12 @@ class Wikipedia(datasets.GeneratorBasedBuilder):
465
  ),
466
  ]
467
 
468
- def _generate_examples(self, filepath):
469
  """This function returns the examples in the raw (text) form."""
470
  logger.info("generating examples from = %s", filepath)
471
 
472
- tbl = pq.ParquetFile(filepath)
473
- for group_i in range(tbl.num_row_groups):
474
- row_group = tbl.read_row_group(group_i)
475
 
476
- for batch in row_group.to_batches():
477
- for row in zip(*batch.columns):
478
- yield str(row[0]), {
479
- "id": str(row[0]),
480
- "url": str(row[1]),
481
- "title": str(row[2]),
482
- "text": str(row[3]),
483
- }
 
419
  _DATE = "20230601"
420
 
421
 
422
+ class Wikipedia(datasets.ArrowBasedBuilder):
423
  """Wikipedia dataset."""
424
 
425
  # Use mirror (your.org) to avoid download caps.
 
465
  ),
466
  ]
467
 
468
+ def _generate_tables(self, filepath):
469
  """This function returns the examples in the raw (text) form."""
470
  logger.info("generating examples from = %s", filepath)
471
 
472
+ pf = pq.ParquetFile(filepath)
 
 
473
 
474
+ for group_i in range(pf.num_row_groups):
475
+ tbl = pf.read_row_group(group_i)
476
+ yield group_i, tbl