Datasets:
shuyangcao
commited on
Commit
•
65e803e
1
Parent(s):
545c018
First version
Browse files- .gitattributes +1 -0
- README.md +202 -0
- data/crs_test.jsonl +3 -0
- data/crs_train.jsonl +3 -0
- data/crs_valid.jsonl +3 -0
- data/gao_test.jsonl +3 -0
- data/gao_train.jsonl +3 -0
- data/gao_valid.jsonl +3 -0
- gov_report.py +225 -0
.gitattributes
CHANGED
@@ -35,3 +35,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
35 |
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
36 |
*.ogg filter=lfs diff=lfs merge=lfs -text
|
37 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
|
|
|
35 |
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
36 |
*.ogg filter=lfs diff=lfs merge=lfs -text
|
37 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
38 |
+
*.jsonl filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- no-annotation
|
4 |
+
language_creators:
|
5 |
+
- expert-generated
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- cc-by-4.0
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- 10K<n<100K
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- summarization
|
18 |
+
task_ids:
|
19 |
+
- summarization
|
20 |
+
pretty_name: GovReport
|
21 |
+
---
|
22 |
+
|
23 |
+
|
24 |
+
# Dataset Card for GovReport
|
25 |
+
|
26 |
+
## Table of Contents
|
27 |
+
- [Table of Contents](#table-of-contents)
|
28 |
+
- [Dataset Description](#dataset-description)
|
29 |
+
- [Dataset Summary](#dataset-summary)
|
30 |
+
- [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
|
31 |
+
- [Languages](#languages)
|
32 |
+
- [Dataset Structure](#dataset-structure)
|
33 |
+
- [Data Instances](#data-instances)
|
34 |
+
- [Data Fields](#data-fields)
|
35 |
+
- [Data Splits](#data-splits)
|
36 |
+
- [Dataset Creation](#dataset-creation)
|
37 |
+
- [Curation Rationale](#curation-rationale)
|
38 |
+
- [Source Data](#source-data)
|
39 |
+
- [Annotations](#annotations)
|
40 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
41 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
42 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
43 |
+
- [Discussion of Biases](#discussion-of-biases)
|
44 |
+
- [Other Known Limitations](#other-known-limitations)
|
45 |
+
- [Additional Information](#additional-information)
|
46 |
+
- [Dataset Curators](#dataset-curators)
|
47 |
+
- [Licensing Information](#licensing-information)
|
48 |
+
- [Citation Information](#citation-information)
|
49 |
+
- [Contributions](#contributions)
|
50 |
+
|
51 |
+
## Dataset Description
|
52 |
+
|
53 |
+
- **Homepage:** [https://gov-report-data.github.io](https://gov-report-data.github.io)
|
54 |
+
- **Repository:** [https://github.com/luyang-huang96/LongDocSum](https://github.com/luyang-huang96/LongDocSum)
|
55 |
+
- **Paper:** [https://aclanthology.org/2021.naacl-main.112/](https://aclanthology.org/2021.naacl-main.112/)
|
56 |
+
- **Leaderboard:** [Needs More Information]
|
57 |
+
- **Point of Contact:** [Needs More Information]
|
58 |
+
|
59 |
+
### Dataset Summary
|
60 |
+
|
61 |
+
Government report dataset consists of reports and associated summaries written by government research agencies including Congressional Research Service and U.S. Government Accountability Office.
|
62 |
+
|
63 |
+
Compared with other long document summarization datasets, government report dataset has longer summaries and documents and requires reading in more context to cover salient words to be summarized.
|
64 |
+
|
65 |
+
### Supported Tasks and Leaderboards
|
66 |
+
|
67 |
+
[More Information Needed]
|
68 |
+
|
69 |
+
### Languages
|
70 |
+
|
71 |
+
English
|
72 |
+
|
73 |
+
## Dataset Structure
|
74 |
+
|
75 |
+
Three configs are available:
|
76 |
+
- **plain_text** (default): the text-to-text summarization setting used as in the original paper.
|
77 |
+
- **plain_text_with_recommendations**: the text-to-text summarization setting, with "What GAO recommends" included in the summary.
|
78 |
+
- **structure**: data with the section structure.
|
79 |
+
|
80 |
+
To use different configs, set the `name` argument of the `load_dataset` function.
|
81 |
+
|
82 |
+
### Data Instances
|
83 |
+
|
84 |
+
#### plain_text & plain_text_with_recommendations
|
85 |
+
|
86 |
+
An example looks as follows.
|
87 |
+
```
|
88 |
+
{
|
89 |
+
"id": "GAO_123456",
|
90 |
+
"document": "This is a test document.",
|
91 |
+
"summary": "This is a test summary"
|
92 |
+
}
|
93 |
+
```
|
94 |
+
|
95 |
+
#### structure
|
96 |
+
|
97 |
+
An example looks as follows.
|
98 |
+
```
|
99 |
+
{
|
100 |
+
"id": "GAO_123456",
|
101 |
+
"document_sections": {
|
102 |
+
"title": ["test docment section 1 title", "test docment section 1.1 title"],
|
103 |
+
"paragraphs": ["test document\nsection 1 paragraphs", "test document\nsection 1.1 paragraphs"],
|
104 |
+
"depth": [1, 2]
|
105 |
+
},
|
106 |
+
"summary_sections": {
|
107 |
+
"title": ["test summary section 1 title", "test summary section 2 title"],
|
108 |
+
"paragraphs": ["test summary\nsection 1 paragraphs", "test summary\nsection 2 paragraphs"]
|
109 |
+
}
|
110 |
+
}
|
111 |
+
```
|
112 |
+
|
113 |
+
### Data Fields
|
114 |
+
|
115 |
+
#### plain_text & plain_text_with_recommendations
|
116 |
+
|
117 |
+
- `id`: a `string` feature.
|
118 |
+
- `document`: a `string` feature.
|
119 |
+
- `summary`: a `string` feature.
|
120 |
+
|
121 |
+
#### structure
|
122 |
+
|
123 |
+
- `id`: a `string` feature.
|
124 |
+
- `document_sections`: a dictionary feature containing lists of (each element corresponds to a section):
|
125 |
+
- `title`: a `string` feature.
|
126 |
+
- `paragraphs`: a of `string` feature, with `\n` separating different paragraphs.
|
127 |
+
- `depth`: a `int32` feature.
|
128 |
+
- `summary_sections`: a dictionary feature containing lists of (each element corresponds to a section):
|
129 |
+
- `title`: a `string` feature.
|
130 |
+
- `paragraphs`: a `string` feature, with `\n` separating different paragraphs.
|
131 |
+
|
132 |
+
### Data Splits
|
133 |
+
|
134 |
+
- train: 17519
|
135 |
+
- valid: 974
|
136 |
+
- test: 973
|
137 |
+
|
138 |
+
## Dataset Creation
|
139 |
+
|
140 |
+
### Curation Rationale
|
141 |
+
|
142 |
+
[More Information Needed]
|
143 |
+
|
144 |
+
### Source Data
|
145 |
+
|
146 |
+
#### Initial Data Collection and Normalization
|
147 |
+
|
148 |
+
[More Information Needed]
|
149 |
+
|
150 |
+
#### Who are the source language producers?
|
151 |
+
|
152 |
+
Editors of the Congressional Research Service and U.S. Government Accountability Office.
|
153 |
+
|
154 |
+
### Personal and Sensitive Information
|
155 |
+
|
156 |
+
None.
|
157 |
+
|
158 |
+
## Considerations for Using the Data
|
159 |
+
|
160 |
+
### Social Impact of Dataset
|
161 |
+
|
162 |
+
[More Information Needed]
|
163 |
+
|
164 |
+
### Discussion of Biases
|
165 |
+
|
166 |
+
[More Information Needed]
|
167 |
+
|
168 |
+
### Other Known Limitations
|
169 |
+
|
170 |
+
[More Information Needed]
|
171 |
+
|
172 |
+
## Additional Information
|
173 |
+
|
174 |
+
### Dataset Curators
|
175 |
+
|
176 |
+
[More Information Needed]
|
177 |
+
|
178 |
+
### Licensing Information
|
179 |
+
|
180 |
+
CC BY 4.0
|
181 |
+
|
182 |
+
### Citation Information
|
183 |
+
|
184 |
+
```
|
185 |
+
@inproceedings{huang-etal-2021-efficient,
|
186 |
+
title = "Efficient Attentions for Long Document Summarization",
|
187 |
+
author = "Huang, Luyang and
|
188 |
+
Cao, Shuyang and
|
189 |
+
Parulian, Nikolaus and
|
190 |
+
Ji, Heng and
|
191 |
+
Wang, Lu",
|
192 |
+
booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
|
193 |
+
month = jun,
|
194 |
+
year = "2021",
|
195 |
+
address = "Online",
|
196 |
+
publisher = "Association for Computational Linguistics",
|
197 |
+
url = "https://aclanthology.org/2021.naacl-main.112",
|
198 |
+
doi = "10.18653/v1/2021.naacl-main.112",
|
199 |
+
pages = "1419--1436",
|
200 |
+
abstract = "The quadratic computational and memory complexities of large Transformers have limited their scalability for long document summarization. In this paper, we propose Hepos, a novel efficient encoder-decoder attention with head-wise positional strides to effectively pinpoint salient information from the source. We further conduct a systematic study of existing efficient self-attentions. Combined with Hepos, we are able to process ten times more tokens than existing models that use full attentions. For evaluation, we present a new dataset, GovReport, with significantly longer documents and summaries. Results show that our models produce significantly higher ROUGE scores than competitive comparisons, including new state-of-the-art results on PubMed. Human evaluation also shows that our models generate more informative summaries with fewer unfaithful errors.",
|
201 |
+
}
|
202 |
+
```
|
data/crs_test.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bef184f1f4249ee4f145214b9f836a277152d5074395b879bd9ea891c519dece
|
3 |
+
size 19779267
|
data/crs_train.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5de865c921b76c4f1bc5f7f73fd38f9eeeef3ab7fe7cff205089853f079f74c6
|
3 |
+
size 359025392
|
data/crs_valid.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f56ff5bdbf381c053f106deadd566ad0ae3324b78c0d6ebe83c69121ecbdd24a
|
3 |
+
size 22496525
|
data/gao_test.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5285ee273ae430003c1e8fdb45ed7c6757349c114d2cae45160845ef60a49a94
|
3 |
+
size 39973256
|
data/gao_train.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ee7a981a768c7f0c68d635e4a3cbfac03b95e45284181232d6c7021d511ea729
|
3 |
+
size 709026557
|
data/gao_valid.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9cae7d5fecbcb507d1e84ecf8d476f26796d50a6690ac7c79fabe7b0e13a9b16
|
3 |
+
size 41604401
|
gov_report.py
ADDED
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""GovReport: The Government Report Long Document Summarization Dataset."""
|
2 |
+
|
3 |
+
|
4 |
+
import json
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
|
9 |
+
logger = datasets.logging.get_logger(__name__)
|
10 |
+
|
11 |
+
|
12 |
+
_CITATION = """\
|
13 |
+
@inproceedings{huang-etal-2021-efficient,
|
14 |
+
title = "Efficient Attentions for Long Document Summarization",
|
15 |
+
author = "Huang, Luyang and
|
16 |
+
Cao, Shuyang and
|
17 |
+
Parulian, Nikolaus and
|
18 |
+
Ji, Heng and
|
19 |
+
Wang, Lu",
|
20 |
+
booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
|
21 |
+
month = jun,
|
22 |
+
year = "2021",
|
23 |
+
address = "Online",
|
24 |
+
publisher = "Association for Computational Linguistics",
|
25 |
+
url = "https://aclanthology.org/2021.naacl-main.112",
|
26 |
+
doi = "10.18653/v1/2021.naacl-main.112",
|
27 |
+
pages = "1419--1436",
|
28 |
+
abstract = "The quadratic computational and memory complexities of large Transformers have limited their scalability for long document summarization. In this paper, we propose Hepos, a novel efficient encoder-decoder attention with head-wise positional strides to effectively pinpoint salient information from the source. We further conduct a systematic study of existing efficient self-attentions. Combined with Hepos, we are able to process ten times more tokens than existing models that use full attentions. For evaluation, we present a new dataset, GovReport, with significantly longer documents and summaries. Results show that our models produce significantly higher ROUGE scores than competitive comparisons, including new state-of-the-art results on PubMed. Human evaluation also shows that our models generate more informative summaries with fewer unfaithful errors.",
|
29 |
+
}
|
30 |
+
"""
|
31 |
+
|
32 |
+
_DESCRIPTION = """\
|
33 |
+
GovReport long document summarization dataset.
|
34 |
+
|
35 |
+
There are three configs:
|
36 |
+
- plain_text: plain text document-to-summary pairs
|
37 |
+
- plain_text_with_recommendations: plain text doucment-summary pairs, with "What GAO recommends" included in the summary
|
38 |
+
- structure: data with section structure
|
39 |
+
"""
|
40 |
+
|
41 |
+
_URL = "https://huggingface.co/datasets/shuyangcao/gov_report/resolve/main/data/"
|
42 |
+
_URLS = {
|
43 |
+
"gao_train": _URL + "gao_train.jsonl",
|
44 |
+
"gao_valid": _URL + "gao_valid.jsonl",
|
45 |
+
"gao_test": _URL + "gao_test.jsonl",
|
46 |
+
"crs_train": _URL + "crs_train.jsonl",
|
47 |
+
"crs_valid": _URL + "crs_valid.jsonl",
|
48 |
+
"crs_test": _URL + "crs_test.jsonl",
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
def _recursive_load(section, keep_letter=False, depth=0):
|
53 |
+
sections = []
|
54 |
+
if section["section_title"] != "Letter" or (section["section_title"] == "Letter" and keep_letter):
|
55 |
+
sections.append({
|
56 |
+
"title": section["section_title"].strip(),
|
57 |
+
"paragraphs": "\n".join(section["paragraphs"]),
|
58 |
+
"depth": depth
|
59 |
+
})
|
60 |
+
for subsection in section["subsections"]:
|
61 |
+
child_sections = _recursive_load(subsection, keep_letter, depth + 1)
|
62 |
+
sections.extend(child_sections)
|
63 |
+
else:
|
64 |
+
for subsection in section["subsections"]:
|
65 |
+
child_sections = _recursive_load(subsection, keep_letter, depth)
|
66 |
+
sections.extend(child_sections)
|
67 |
+
|
68 |
+
return sections
|
69 |
+
|
70 |
+
|
71 |
+
class GovReportConfig(datasets.BuilderConfig):
|
72 |
+
"""BuilderConfig for GovReport."""
|
73 |
+
|
74 |
+
def __init__(self, **kwargs):
|
75 |
+
"""BuilderConfig for GovReport.
|
76 |
+
Args:
|
77 |
+
**kwargs: keyword arguments forwarded to super.
|
78 |
+
"""
|
79 |
+
super(GovReportConfig, self).__init__(**kwargs)
|
80 |
+
|
81 |
+
|
82 |
+
class GovReport(datasets.GeneratorBasedBuilder):
|
83 |
+
VERSION = datasets.Version("1.0.0")
|
84 |
+
|
85 |
+
DEFAULT_CONFIG_NAME = "plain_text"
|
86 |
+
|
87 |
+
BUILDER_CONFIGS = [
|
88 |
+
GovReportConfig(
|
89 |
+
name="plain_text",
|
90 |
+
version=VERSION,
|
91 |
+
description="Plain text",
|
92 |
+
),
|
93 |
+
GovReportConfig(
|
94 |
+
name="plain_text_with_recommendations",
|
95 |
+
version=VERSION,
|
96 |
+
description="Plain text with GAO recommendations",
|
97 |
+
),
|
98 |
+
GovReportConfig(
|
99 |
+
name="structure",
|
100 |
+
version=VERSION,
|
101 |
+
description="structure data",
|
102 |
+
)
|
103 |
+
]
|
104 |
+
|
105 |
+
def _info(self):
|
106 |
+
if self.config.name in ["plain_text", "plain_text_with_recommendations"]:
|
107 |
+
features = datasets.Features(
|
108 |
+
{
|
109 |
+
"id": datasets.Value("string"),
|
110 |
+
"document": datasets.Value("string"),
|
111 |
+
"summary": datasets.Value("string")
|
112 |
+
}
|
113 |
+
)
|
114 |
+
elif self.config.name == "structure":
|
115 |
+
features = datasets.Features(
|
116 |
+
{
|
117 |
+
"id": datasets.Value("string"),
|
118 |
+
"document_sections": datasets.features.Sequence(
|
119 |
+
{
|
120 |
+
"title": datasets.Value("string"),
|
121 |
+
"paragraphs": datasets.Value("string"),
|
122 |
+
"depth": datasets.Value("int32"),
|
123 |
+
}
|
124 |
+
),
|
125 |
+
"summary_sections": datasets.features.Sequence(
|
126 |
+
{
|
127 |
+
"title": datasets.Value("string"),
|
128 |
+
"paragraphs": datasets.Value("string"),
|
129 |
+
}
|
130 |
+
),
|
131 |
+
}
|
132 |
+
)
|
133 |
+
else:
|
134 |
+
raise ValueError("Unsupported config name {}".format(self.config.name))
|
135 |
+
|
136 |
+
return datasets.DatasetInfo(
|
137 |
+
description=_DESCRIPTION,
|
138 |
+
features=features,
|
139 |
+
supervised_keys=None,
|
140 |
+
homepage="",
|
141 |
+
citation=_CITATION,
|
142 |
+
)
|
143 |
+
|
144 |
+
def _split_generators(self, dl_manager):
|
145 |
+
downloaded_files = dl_manager.download_and_extract(_URLS)
|
146 |
+
|
147 |
+
return [
|
148 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"gao_filepath": downloaded_files["gao_train"], "crs_filepath": downloaded_files["crs_train"]}),
|
149 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"gao_filepath": downloaded_files["gao_valid"], "crs_filepath": downloaded_files["crs_valid"]}),
|
150 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"gao_filepath": downloaded_files["gao_test"], "crs_filepath": downloaded_files["crs_test"]}),
|
151 |
+
]
|
152 |
+
|
153 |
+
def _generate_examples(self, gao_filepath, crs_filepath):
|
154 |
+
"""This function returns the examples in the raw (text) form."""
|
155 |
+
logger.info(f"generating examples from = (GAO) {gao_filepath} and (CRS) {crs_filepath}")
|
156 |
+
|
157 |
+
with open(gao_filepath, "r") as f:
|
158 |
+
for line in f:
|
159 |
+
line = line.strip()
|
160 |
+
if not line:
|
161 |
+
continue
|
162 |
+
data = json.loads(line)
|
163 |
+
|
164 |
+
_id = 'GAO_' + data["id"]
|
165 |
+
|
166 |
+
document_sections = []
|
167 |
+
for lv1_section in data["report"]:
|
168 |
+
document_sections.extend(_recursive_load(lv1_section, keep_letter=False, depth=1))
|
169 |
+
summary_sections = [
|
170 |
+
{
|
171 |
+
"title": " ".join(highlight_section["section_title"].strip().split()),
|
172 |
+
"paragraphs": "\n".join([" ".join(paragraph.strip().split()) for paragraph in highlight_section["paragraphs"]])
|
173 |
+
} for highlight_section in data["highlight"]
|
174 |
+
]
|
175 |
+
|
176 |
+
if self.config.name == "plain_text":
|
177 |
+
yield _id, {
|
178 |
+
"id": _id,
|
179 |
+
"document": " ".join([section["title"] + " " + section["paragraphs"] if section["paragraphs"] else section["title"] for section in document_sections]).replace("\n", " ").strip(),
|
180 |
+
"summary": " ".join([section["paragraphs"] for section in summary_sections if section["title"] != "What GAO Recommends"]).replace("\n", " ").strip(),
|
181 |
+
}
|
182 |
+
elif self.config.name == "plain_text_with_recommendations":
|
183 |
+
yield _id, {
|
184 |
+
"id": _id,
|
185 |
+
"document": " ".join([section["title"] + " " + section["paragraphs"] if section["paragraphs"] else section["title"] for section in document_sections]).replace("\n", " ").strip(),
|
186 |
+
"summary": " ".join([section["paragraphs"] for section in summary_sections]).replace("\n", " ").strip(),
|
187 |
+
}
|
188 |
+
elif self.config.name == "structure":
|
189 |
+
yield _id, {
|
190 |
+
"id": _id,
|
191 |
+
"document_sections": document_sections,
|
192 |
+
"summary_sections": summary_sections
|
193 |
+
}
|
194 |
+
else:
|
195 |
+
raise ValueError("Unsupported config name {}".format(self.config.name))
|
196 |
+
|
197 |
+
with open(crs_filepath, "r") as f:
|
198 |
+
for line in f:
|
199 |
+
line = line.strip()
|
200 |
+
if not line:
|
201 |
+
continue
|
202 |
+
data = json.loads(line)
|
203 |
+
|
204 |
+
_id = 'CRS_' + data["id"]
|
205 |
+
|
206 |
+
document_sections = _recursive_load(data["reports"], keep_letter=True, depth=0)
|
207 |
+
summary_sections = [{
|
208 |
+
"title": "",
|
209 |
+
"paragraphs": "\n".join([" ".join(paragraph.strip().split()) for paragraph in data["summary"]])
|
210 |
+
}]
|
211 |
+
|
212 |
+
if self.config.name in ["plain_text", "plain_text_with_recommendations"]:
|
213 |
+
yield _id, {
|
214 |
+
"id": _id,
|
215 |
+
"document": " ".join([section["title"] + " " + section["paragraphs"] if section["paragraphs"] else section["title"] for section in document_sections]).replace("\n", " ").strip(),
|
216 |
+
"summary": " ".join([section["paragraphs"] for section in summary_sections]).replace("\n", " ").strip(),
|
217 |
+
}
|
218 |
+
elif self.config.name == "structure":
|
219 |
+
yield _id, {
|
220 |
+
"id": _id,
|
221 |
+
"document_sections": document_sections,
|
222 |
+
"summary_sections": summary_sections
|
223 |
+
}
|
224 |
+
else:
|
225 |
+
raise ValueError("Unsupported config name {}".format(self.config.name))
|