Delete loading script
Browse files- summarization.py +0 -78
summarization.py
DELETED
|
@@ -1,78 +0,0 @@
|
|
| 1 |
-
import datasets
|
| 2 |
-
import os
|
| 3 |
-
import json
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
_CITATION = ""
|
| 7 |
-
_DESCRIPTION = """
|
| 8 |
-
Scenario for single document text summarization.
|
| 9 |
-
Currently supports the following datasets:
|
| 10 |
-
1. XSum (https://arxiv.org/pdf/1808.08745.pdf)
|
| 11 |
-
2. CNN/DailyMail non-anonymized (https://arxiv.org/pdf/1704.04368.pdf)
|
| 12 |
-
|
| 13 |
-
Task prompt structure
|
| 14 |
-
|
| 15 |
-
Summarize the given document.
|
| 16 |
-
Document: {tok_1 ... tok_n}
|
| 17 |
-
Summary: {tok_1 ... tok_m}
|
| 18 |
-
|
| 19 |
-
Example from XSum dataset
|
| 20 |
-
|
| 21 |
-
Document: {Part of the Broad Road was closed to traffic on Sunday at about 18:00 GMT.
|
| 22 |
-
The three adults and three children have been taken to Altnagelvin Hospital
|
| 23 |
-
with non life-threatening injuries. The Fire Service, Northern Ireland Ambulance Service
|
| 24 |
-
and police attended the crash. The Broad Road has since been reopened.}
|
| 25 |
-
Summary: {Three adults and three children have been taken to hospital following a crash involving
|
| 26 |
-
a tractor and a campervan in Limavady, County Londonderry}
|
| 27 |
-
"""
|
| 28 |
-
|
| 29 |
-
class Summarization(datasets.GeneratorBasedBuilder):
|
| 30 |
-
VERSION = datasets.Version("1.0.0")
|
| 31 |
-
|
| 32 |
-
BUILDER_CONFIGS = [
|
| 33 |
-
datasets.BuilderConfig(name=name, version=datasets.Version("1.0.0"), description="")
|
| 34 |
-
for name in ["xsum", "xsum-sampled", "cnn-dm"]
|
| 35 |
-
]
|
| 36 |
-
|
| 37 |
-
def _info(self):
|
| 38 |
-
features = datasets.Features(
|
| 39 |
-
{
|
| 40 |
-
"article": datasets.Value("string"),
|
| 41 |
-
"summary": datasets.Value("string"),
|
| 42 |
-
|
| 43 |
-
}
|
| 44 |
-
)
|
| 45 |
-
return datasets.DatasetInfo(
|
| 46 |
-
description=_DESCRIPTION,
|
| 47 |
-
features=features,
|
| 48 |
-
homepage="",
|
| 49 |
-
license="",
|
| 50 |
-
citation=_CITATION,
|
| 51 |
-
)
|
| 52 |
-
|
| 53 |
-
def _split_generators(self, dl_manager):
|
| 54 |
-
train_json = dl_manager.download(os.path.join(self.config.name, "train.jsonl"))
|
| 55 |
-
test_json = dl_manager.download(os.path.join(self.config.name, "test.jsonl"))
|
| 56 |
-
val_json = dl_manager.download(os.path.join(self.config.name, "validation.jsonl"))
|
| 57 |
-
|
| 58 |
-
return [
|
| 59 |
-
datasets.SplitGenerator(
|
| 60 |
-
name=datasets.Split.TRAIN,
|
| 61 |
-
gen_kwargs={"path": train_json},
|
| 62 |
-
),
|
| 63 |
-
datasets.SplitGenerator(
|
| 64 |
-
name=datasets.Split.TEST,
|
| 65 |
-
gen_kwargs={"path": test_json},
|
| 66 |
-
),
|
| 67 |
-
datasets.SplitGenerator(
|
| 68 |
-
name=datasets.Split.VALIDATION,
|
| 69 |
-
gen_kwargs={"path": val_json},
|
| 70 |
-
)
|
| 71 |
-
]
|
| 72 |
-
|
| 73 |
-
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 74 |
-
def _generate_examples(self, path):
|
| 75 |
-
with open(path, encoding="utf-8") as f:
|
| 76 |
-
for key, row in enumerate(f):
|
| 77 |
-
yield key, json.loads(row)
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|