Datasets:
Commit
•
2bc4c74
1
Parent(s):
a5b5596
Delete loading script
Browse files- govreport-summarization.py +0 -96
govreport-summarization.py
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
import json
|
2 |
-
import os
|
3 |
-
import datasets
|
4 |
-
from datasets.tasks import TextClassification
|
5 |
-
|
6 |
-
_DESCRIPTION = """
|
7 |
-
GovReport dataset for summarization.
|
8 |
-
From paper: Efficient Attentions for Long Document Summarization" by L. Huang et al.
|
9 |
-
See: https://arxiv.org/pdf/2104.02112.pdf
|
10 |
-
See: https://github.com/luyang-huang96/LongDocSum
|
11 |
-
"""
|
12 |
-
_CITATION = """\
|
13 |
-
@misc{huang2021efficient,
|
14 |
-
title={Efficient Attentions for Long Document Summarization},
|
15 |
-
author={Luyang Huang and Shuyang Cao and Nikolaus Parulian and Heng Ji and Lu Wang},
|
16 |
-
year={2021},
|
17 |
-
eprint={2104.02112},
|
18 |
-
archivePrefix={arXiv},
|
19 |
-
primaryClass={cs.CL}
|
20 |
-
}
|
21 |
-
}
|
22 |
-
"""
|
23 |
-
_ABSTRACT = "summary"
|
24 |
-
_ARTICLE = "report"
|
25 |
-
|
26 |
-
class GovReportSummarizationConfig(datasets.BuilderConfig):
|
27 |
-
"""BuilderConfig for GovReportSummarization."""
|
28 |
-
|
29 |
-
def __init__(self, **kwargs):
|
30 |
-
"""BuilderConfig for GovReportSummarization.
|
31 |
-
Args:
|
32 |
-
**kwargs: keyword arguments forwarded to super.
|
33 |
-
"""
|
34 |
-
super(GovReportSummarizationConfig, self).__init__(**kwargs)
|
35 |
-
|
36 |
-
|
37 |
-
class GovReportSummarizationDataset(datasets.GeneratorBasedBuilder):
|
38 |
-
"""GovReportSummarization Dataset."""
|
39 |
-
|
40 |
-
_TRAIN_FILE = "train.zip"
|
41 |
-
_VAL_FILE = "valid.zip"
|
42 |
-
_TEST_FILE = "test.zip"
|
43 |
-
|
44 |
-
BUILDER_CONFIGS = [
|
45 |
-
GovReportSummarizationConfig(
|
46 |
-
name="document",
|
47 |
-
version=datasets.Version("1.0.0"),
|
48 |
-
description="GovReport dataset for summarization, document",
|
49 |
-
),
|
50 |
-
]
|
51 |
-
|
52 |
-
DEFAULT_CONFIG_NAME = "document"
|
53 |
-
|
54 |
-
def _info(self):
|
55 |
-
# Should return a datasets.DatasetInfo object
|
56 |
-
return datasets.DatasetInfo(
|
57 |
-
description=_DESCRIPTION,
|
58 |
-
features=datasets.Features(
|
59 |
-
{
|
60 |
-
_ARTICLE: datasets.Value("string"),
|
61 |
-
_ABSTRACT: datasets.Value("string"),
|
62 |
-
#"id": datasets.Value("string"),
|
63 |
-
}
|
64 |
-
),
|
65 |
-
supervised_keys=None,
|
66 |
-
homepage="https://github.com/luyang-huang96/LongDocSum",
|
67 |
-
citation=_CITATION,
|
68 |
-
)
|
69 |
-
|
70 |
-
def _split_generators(self, dl_manager):
|
71 |
-
|
72 |
-
train_path = os.path.join(dl_manager.download_and_extract(self._TRAIN_FILE), "train.txt")
|
73 |
-
val_path = os.path.join(dl_manager.download_and_extract(self._VAL_FILE), "valid.txt")
|
74 |
-
test_path = os.path.join(dl_manager.download_and_extract(self._TEST_FILE), "test.txt")
|
75 |
-
|
76 |
-
return [
|
77 |
-
datasets.SplitGenerator(
|
78 |
-
name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}
|
79 |
-
),
|
80 |
-
datasets.SplitGenerator(
|
81 |
-
name=datasets.Split.VALIDATION, gen_kwargs={"filepath": val_path}
|
82 |
-
),
|
83 |
-
datasets.SplitGenerator(
|
84 |
-
name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}
|
85 |
-
),
|
86 |
-
]
|
87 |
-
|
88 |
-
def _generate_examples(self, filepath):
|
89 |
-
"""Generate GovReportSummarization examples."""
|
90 |
-
with open(filepath, encoding="utf-8") as f:
|
91 |
-
for id_, row in enumerate(f):
|
92 |
-
data = json.loads(row)
|
93 |
-
report = data["report"]
|
94 |
-
summary = data["summary"]
|
95 |
-
|
96 |
-
yield id_, {"report": report, "summary": summary}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|