BeeGass commited on
Commit
9a95f7e
·
verified ·
1 Parent(s): 9fb4c93

Upload permutation-groups.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. permutation-groups.py +10 -18
permutation-groups.py CHANGED
@@ -174,27 +174,19 @@ class PermutationGroups(datasets.GeneratorBasedBuilder):
174
 
175
  def _generate_examples(self, filepaths, split):
176
  # Load the Arrow files and yield examples
177
- import pyarrow as pa
178
-
179
  # Handle both single filepath and list of filepaths
180
  if isinstance(filepaths, str):
181
  filepaths = [filepaths]
182
 
183
  example_id = 0
184
  for filepath in filepaths:
185
- # Read the arrow file
186
- with open(filepath, "rb") as f:
187
- # Read arrow file using pyarrow
188
- reader = pa.ipc.open_file(f)
189
- table = reader.read_all()
190
-
191
- # Convert to pandas for easier iteration
192
- df = table.to_pandas()
193
-
194
- # Yield each row as an example
195
- for idx, row in df.iterrows():
196
- yield example_id, {
197
- "input_sequence": row["input_sequence"],
198
- "target": row["target"],
199
- }
200
- example_id += 1
 
174
 
175
  def _generate_examples(self, filepaths, split):
176
  # Load the Arrow files and yield examples
 
 
177
  # Handle both single filepath and list of filepaths
178
  if isinstance(filepaths, str):
179
  filepaths = [filepaths]
180
 
181
  example_id = 0
182
  for filepath in filepaths:
183
+ # Load the arrow file using datasets library
184
+ dataset = datasets.Dataset.from_file(filepath)
185
+
186
+ # Yield each row as an example
187
+ for row in dataset:
188
+ yield example_id, {
189
+ "input_sequence": row["input_sequence"],
190
+ "target": row["target"],
191
+ }
192
+ example_id += 1