Theoreticallyhugo commited on
Commit
9e76666
·
1 Parent(s): bfcbdd5

improved split handling

Browse files
Files changed (1) hide show
  1. essays_SuG.py +32 -2
essays_SuG.py CHANGED
@@ -302,7 +302,7 @@ class Fancy(datasets.GeneratorBasedBuilder):
302
  train, test, validate = self._range_generator(1, 0)
303
  essays = self._get_essay_list()
304
 
305
- if len(validate) > 0:
306
  return [
307
  datasets.SplitGenerator(
308
  name=datasets.Split.TRAIN,
@@ -329,7 +329,7 @@ class Fancy(datasets.GeneratorBasedBuilder):
329
  },
330
  ),
331
  ]
332
- else:
333
  return [
334
  datasets.SplitGenerator(
335
  name=datasets.Split.TRAIN,
@@ -348,6 +348,36 @@ class Fancy(datasets.GeneratorBasedBuilder):
348
  },
349
  ),
350
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
 
352
  def _get_id(self, essay):
353
  return int(essay["docID"].split("_")[-1])
 
302
  train, test, validate = self._range_generator(1, 0)
303
  essays = self._get_essay_list()
304
 
305
+ if len(validate) > 0 and len(test) > 0:
306
  return [
307
  datasets.SplitGenerator(
308
  name=datasets.Split.TRAIN,
 
329
  },
330
  ),
331
  ]
332
+ elif len(validate) == 0:
333
  return [
334
  datasets.SplitGenerator(
335
  name=datasets.Split.TRAIN,
 
348
  },
349
  ),
350
  ]
351
+ elif len(test) == 0:
352
+ return [
353
+ datasets.SplitGenerator(
354
+ name=datasets.Split.TRAIN,
355
+ # These kwargs will be passed to _generate_examples
356
+ gen_kwargs={
357
+ "data": essays,
358
+ "id_range": train,
359
+ },
360
+ ),
361
+ datasets.SplitGenerator(
362
+ name=datasets.Split.VALIDATION,
363
+ # These kwargs will be passed to _generate_examples
364
+ gen_kwargs={
365
+ "data": essays,
366
+ "id_range": validate,
367
+ },
368
+ ),
369
+ ]
370
+ else:
371
+ return [
372
+ datasets.SplitGenerator(
373
+ name=datasets.Split.TRAIN,
374
+ # These kwargs will be passed to _generate_examples
375
+ gen_kwargs={
376
+ "data": essays,
377
+ "id_range": train,
378
+ },
379
+ ),
380
+ ]
381
 
382
  def _get_id(self, essay):
383
  return int(essay["docID"].split("_")[-1])