Datasets:

Modalities:
Text
ArXiv:
Libraries:
Datasets
lovodkin93 commited on
Commit
9e5af79
1 Parent(s): 7a8767c
Files changed (1) hide show
  1. Controlled-Text-Reduction-dataset.py +88 -43
Controlled-Text-Reduction-dataset.py CHANGED
@@ -300,25 +300,25 @@ SOFTWARE."""
300
 
301
 
302
 
303
- # _URLs = {
304
- # "DUC-2001-2002": {
305
- # "dev": "https://github.com/lovodkin93/Controlled_Text_Reduction/tree/main/data/dev_DUC-2001-2002.csv",
306
- # "test": "https://github.com/lovodkin93/Controlled_Text_Reduction/tree/main/data/test_DUC-2001-2002.csv",
307
- # "train": "https://github.com/lovodkin93/Controlled_Text_Reduction/tree/main/data/train_DUC-2001-2002.csv"
308
- # },
309
- # "CNN-DM": {
310
- # "train": "https://github.com/lovodkin93/Controlled_Text_Reduction/tree/main/data/train_CNNDM.csv",
311
- # "dev": "https://github.com/lovodkin93/Controlled_Text_Reduction/tree/main/data/dev_DUC-2001-2002.csv",
312
- # "test": "https://github.com/lovodkin93/Controlled_Text_Reduction/tree/main/data/test_DUC-2001-2002.csv",
313
- # },
314
- # }
315
-
316
  _URLs = {
317
- "dev_DUC-2001-2002": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/dev_DUC-2001-2002.csv",
318
- "test_DUC-2001-2002": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/test_DUC-2001-2002.csv",
319
- "train_DUC-2001-2002": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/train_DUC-2001-2002.csv"
 
 
 
 
 
 
 
320
  }
321
 
 
 
 
 
 
 
322
 
323
  COLUMNS = ["doc_text", "summary_text", "highlight_spans"]
324
 
@@ -398,37 +398,82 @@ class ControlledTectReduction(datasets.GeneratorBasedBuilder):
398
  # Citation for the dataset
399
  citation=_CITATION,
400
  )
 
401
 
402
  def _split_generators(self, dl_manager: datasets.utils.download_manager.DownloadManager):
403
  """Returns SplitGenerators."""
404
 
405
- # Download and prepare all files - keep same structure as _URLs
406
- corpora = {section: Path(dl_manager.download_and_extract(_URLs[section]))
407
- for section in _URLs}
408
-
409
- return [
410
- datasets.SplitGenerator(
411
- name=datasets.Split.TRAIN,
412
- # These kwargs will be passed to _generate_examples
413
- gen_kwargs={
414
- "filepath": corpora["train_DUC-2001-2002"],
415
- },
416
- ),
417
- datasets.SplitGenerator(
418
- name=datasets.Split.VALIDATION,
419
- # These kwargs will be passed to _generate_examples
420
- gen_kwargs={
421
- "filepath": corpora["dev_DUC-2001-2002"],
422
- },
423
- ),
424
- datasets.SplitGenerator(
425
- name=datasets.Split.TEST,
426
- # These kwargs will be passed to _generate_examples
427
- gen_kwargs={
428
- "filepath": corpora["test_DUC-2001-2002"],
429
- },
430
- ),
431
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
 
433
  def _generate_examples(self, filepath: List[str]):
434
 
 
300
 
301
 
302
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  _URLs = {
304
+ "DUC-2001-2002": {
305
+ "train": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/train_DUC-2001-2002.csv",
306
+ "dev": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/dev_DUC-2001-2002.csv",
307
+ "test": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/test_DUC-2001-2002.csv",
308
+ },
309
+ "CNN-DM": {
310
+ "train": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/train_CNNDM.csv",
311
+ "dev": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/dev_DUC-2001-2002.csv",
312
+ "test": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/test_DUC-2001-2002.csv",
313
+ },
314
  }
315
 
316
+ # _URLs = {
317
+ # "dev_DUC-2001-2002": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/dev_DUC-2001-2002.csv",
318
+ # "test_DUC-2001-2002": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/test_DUC-2001-2002.csv",
319
+ # "train_DUC-2001-2002": "https://media.githubusercontent.com/media/lovodkin93/Controlled_Text_Reduction/main/data/train_DUC-2001-2002.csv"
320
+ # }
321
+
322
 
323
  COLUMNS = ["doc_text", "summary_text", "highlight_spans"]
324
 
 
398
  # Citation for the dataset
399
  citation=_CITATION,
400
  )
401
+
402
 
403
  def _split_generators(self, dl_manager: datasets.utils.download_manager.DownloadManager):
404
  """Returns SplitGenerators."""
405
 
406
+ URLs = _URLs[self.config.data_source]
407
+ # Download and prepare all files - keep same structure as URLs
408
+ corpora = {section: Path(dl_manager.download_and_extract(URLs[section]))
409
+ for section in URLs}
410
+
411
+ if self.config.data_source=="CNN-DM":
412
+ return [
413
+ datasets.SplitGenerator(
414
+ name=datasets.Split.TRAIN,
415
+ # These kwargs will be passed to _generate_examples
416
+ gen_kwargs={
417
+ "filepath": corpora["train"]
418
+ },
419
+ ),
420
+ datasets.SplitGenerator(
421
+ name=datasets.Split.VALIDATION,
422
+ # These kwargs will be passed to _generate_examples
423
+ gen_kwargs={
424
+ "filepath": corpora["dev"]
425
+ },
426
+ ),
427
+ datasets.SplitGenerator(
428
+ name=datasets.Split.TEST,
429
+ # These kwargs will be passed to _generate_examples
430
+ gen_kwargs={
431
+ "filepath": corpora["test"]
432
+ },
433
+ ),
434
+ ]
435
+
436
+ else:
437
+ return [
438
+ datasets.SplitGenerator(
439
+ name=datasets.Split.TRAIN,
440
+ # These kwargs will be passed to _generate_examples
441
+ gen_kwargs={
442
+ "filepath": corpora["train"]
443
+ },
444
+ ),
445
+ datasets.SplitGenerator(
446
+ name=datasets.Split.VALIDATION,
447
+ # These kwargs will be passed to _generate_examples
448
+ gen_kwargs={
449
+ "filepath": corpora["dev"]
450
+ },
451
+ ),
452
+ datasets.SplitGenerator(
453
+ name=datasets.Split.TEST,
454
+ # These kwargs will be passed to _generate_examples
455
+ gen_kwargs={
456
+ "filepath": corpora["test"]
457
+ },
458
+ ),
459
+ ]
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
469
+
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
 
478
  def _generate_examples(self, filepath: List[str]):
479