Commit
•
be5c5ac
1
Parent(s):
4a8d97f
First version of the climabench dataset.
Browse files- README.md +28 -0
- climabench.py +519 -0
README.md
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
annotations_creators:
|
2 |
+
- other
|
3 |
+
language_creators:
|
4 |
+
- other
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
license:
|
8 |
+
- ""
|
9 |
+
multilinguality:
|
10 |
+
- monolingual
|
11 |
+
size_categories:
|
12 |
+
- 10K<n<100K
|
13 |
+
source_datasets:
|
14 |
+
- original
|
15 |
+
task_categories:
|
16 |
+
- text-classification
|
17 |
+
paperswithcode_id: climabench
|
18 |
+
pretty_name: ClimaBench: A Benchmark Dataset For Climate Change Text Understanding in English
|
19 |
+
|
20 |
+
config_names:
|
21 |
+
- climate_stance
|
22 |
+
- climate_eng
|
23 |
+
- climate_fever
|
24 |
+
- climatext
|
25 |
+
- clima_insurance
|
26 |
+
- clima_insurance_plus
|
27 |
+
- clima_cdp
|
28 |
+
- clima_qa
|
climabench.py
ADDED
@@ -0,0 +1,519 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
"""ClimaBench: A Benchmark Dataset For Climate Change Text Understanding in English"""
|
17 |
+
|
18 |
+
import os
|
19 |
+
import datasets
|
20 |
+
import csv
|
21 |
+
import textwrap
|
22 |
+
import json
|
23 |
+
|
24 |
+
|
25 |
+
_CITATION = """
|
26 |
+
@misc{laud2023climabench,
|
27 |
+
title={ClimaBench: A Benchmark Dataset For Climate Change Text Understanding in English},
|
28 |
+
author={Tanmay Laud and Daniel Spokoyny and Tom Corringham and Taylor Berg-Kirkpatrick},
|
29 |
+
year={2023},
|
30 |
+
eprint={2301.04253},
|
31 |
+
archivePrefix={arXiv},
|
32 |
+
primaryClass={cs.CL}
|
33 |
+
}
|
34 |
+
"""
|
35 |
+
|
36 |
+
_DESCRIPTION = """\
|
37 |
+
The topic of Climate Change (CC) has received limited attention in NLP despite its real world urgency.
|
38 |
+
Activists and policy-makers need NLP tools in order to effectively process the vast and rapidly growing textual data produced on CC.
|
39 |
+
Their utility, however, primarily depends on whether the current state-of-the-art models can generalize across various tasks in the CC domain.
|
40 |
+
In order to address this gap, we introduce Climate Change Benchmark (ClimaBench), a benchmark collection of existing disparate datasets for evaluating model performance across a diverse set of CC NLU tasks systematically.
|
41 |
+
Further, we enhance the benchmark by releasing two large-scale labelled text classification and question-answering datasets curated from publicly available environmental disclosures.
|
42 |
+
Lastly, we provide an analysis of several generic and CC-oriented models answering whether fine-tuning on domain text offers any improvements across these tasks. We hope this work provides a standard assessment tool for research on CC text data.
|
43 |
+
"""
|
44 |
+
|
45 |
+
_HOMEPAGE = "https://arxiv.org/abs/2301.04253"
|
46 |
+
|
47 |
+
_LICENSE = ""
|
48 |
+
|
49 |
+
_URL = "https://drive.google.com/u/0/uc?id=1RnZDC-KMOx8JkhbrFl86TsDpsskZB6fO&export=download&confirm=t&uuid=33b5ea55-a99a-431c-b805-0f298ed2912a&at=AKKF8vzyC_uPCdXvV4-gPlJ11X1J:1688024195786"
|
50 |
+
|
51 |
+
_CLIMABENCH_BASE_KWARGS = dict(
|
52 |
+
citation=_CITATION,
|
53 |
+
url=_HOMEPAGE,
|
54 |
+
)
|
55 |
+
|
56 |
+
|
57 |
+
class ClimaBenchConfig(datasets.BuilderConfig):
|
58 |
+
"""BuilderConfig for ClimaBench."""
|
59 |
+
|
60 |
+
def __init__(
|
61 |
+
self,
|
62 |
+
data_dir,
|
63 |
+
citation,
|
64 |
+
url=None,
|
65 |
+
text_features=None,
|
66 |
+
label_column=None,
|
67 |
+
label_classes=None,
|
68 |
+
process_label=lambda x: x,
|
69 |
+
**kwargs,
|
70 |
+
):
|
71 |
+
"""BuilderConfig for ClimaBench.
|
72 |
+
Args:
|
73 |
+
text_features: `dict[string, string]`, map from the name of the feature
|
74 |
+
dict for each text field to the name of the column in the tsv file
|
75 |
+
label_column: `string`, name of the column in the tsv file corresponding
|
76 |
+
to the label
|
77 |
+
data_dir: `string`, the path to the folder containing the tsv files in the
|
78 |
+
downloaded zip
|
79 |
+
citation: `string`, citation for the data set
|
80 |
+
url: `string`, url for information about the data set
|
81 |
+
label_classes: `list[string]`, the list of classes if the label is
|
82 |
+
categorical. If not provided, then the label will be of type
|
83 |
+
`datasets.Value('float32')`.
|
84 |
+
process_label: `Function[string, any]`, function taking in the raw value
|
85 |
+
of the label and processing it to the form required by the label feature
|
86 |
+
**kwargs: keyword arguments forwarded to super.
|
87 |
+
"""
|
88 |
+
super(ClimaBenchConfig, self).__init__(
|
89 |
+
version=datasets.Version("1.0.0", ""), **kwargs
|
90 |
+
)
|
91 |
+
self.text_features = text_features
|
92 |
+
self.label_column = label_column
|
93 |
+
self.label_classes = label_classes
|
94 |
+
self.data_dir = data_dir
|
95 |
+
self.citation = citation
|
96 |
+
self.url = url
|
97 |
+
self.process_label = process_label
|
98 |
+
|
99 |
+
|
100 |
+
class ClimaBench(datasets.GeneratorBasedBuilder):
|
101 |
+
"""FLORES-200 dataset."""
|
102 |
+
|
103 |
+
BUILDER_CONFIGS = [
|
104 |
+
ClimaBenchConfig(
|
105 |
+
name="climate_stance",
|
106 |
+
description=textwrap.dedent(
|
107 |
+
"""\
|
108 |
+
With climate change becoming a cause of concern worldwide, it becomes essential to gauge people{'}s reactions. This can help educate and spread awareness about it and help leaders improve decision-making. This work explores the fine-grained classification and Stance detection of climate change-related social media text. Firstly, we create two datasets, ClimateStance and ClimateEng, consisting of 3777 tweets each, posted during the 2019 United Nations Framework Convention on Climate Change and comprehensively outline the dataset collection, annotation methodology, and dataset composition. Secondly, we propose the task of Climate Change stance detection based on our proposed ClimateStance dataset. Thirdly, we propose a fine-grained classification based on the ClimateEng dataset, classifying social media text into five categories: Disaster, Ocean/Water, Agriculture/Forestry, Politics, and General. We benchmark both the datasets for climate change stance detection and fine-grained classification using state-of-the-art methods in text classification. We also create a Reddit-based dataset for both the tasks, ClimateReddit, consisting of 6262 pseudo-labeled comments along with 329 manually annotated comments for the label. We then perform semi-supervised experiments for both the tasks and benchmark their results using the best-performing model for the supervised experiments. Lastly, we provide insights into the ClimateStance and ClimateReddit using part-of-speech tagging and named-entity recognition."""
|
109 |
+
),
|
110 |
+
text_features={"text": "text"},
|
111 |
+
label_classes=[0, 1, 2],
|
112 |
+
label_column="label",
|
113 |
+
data_dir="all_data/ClimateStance",
|
114 |
+
citation=textwrap.dedent(
|
115 |
+
"""\
|
116 |
+
@inproceedings{vaid-etal-2022-towards,
|
117 |
+
title = "Towards Fine-grained Classification of Climate Change related Social Media Text",
|
118 |
+
author = "Vaid, Roopal and
|
119 |
+
Pant, Kartikey and
|
120 |
+
Shrivastava, Manish",
|
121 |
+
booktitle = "Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics: Student Research Workshop",
|
122 |
+
month = may,
|
123 |
+
year = "2022",
|
124 |
+
address = "Dublin, Ireland",
|
125 |
+
publisher = "Association for Computational Linguistics",
|
126 |
+
url = "https://aclanthology.org/2022.acl-srw.35",
|
127 |
+
doi = "10.18653/v1/2022.acl-srw.35",
|
128 |
+
pages = "434--443",
|
129 |
+
abstract = "With climate change becoming a cause of concern worldwide, it becomes essential to gauge people{'}s reactions. This can help educate and spread awareness about it and help leaders improve decision-making. This work explores the fine-grained classification and Stance detection of climate change-related social media text. Firstly, we create two datasets, ClimateStance and ClimateEng, consisting of 3777 tweets each, posted during the 2019 United Nations Framework Convention on Climate Change and comprehensively outline the dataset collection, annotation methodology, and dataset composition. Secondly, we propose the task of Climate Change stance detection based on our proposed ClimateStance dataset. Thirdly, we propose a fine-grained classification based on the ClimateEng dataset, classifying social media text into five categories: Disaster, Ocean/Water, Agriculture/Forestry, Politics, and General. We benchmark both the datasets for climate change stance detection and fine-grained classification using state-of-the-art methods in text classification. We also create a Reddit-based dataset for both the tasks, ClimateReddit, consisting of 6262 pseudo-labeled comments along with 329 manually annotated comments for the label. We then perform semi-supervised experiments for both the tasks and benchmark their results using the best-performing model for the supervised experiments. Lastly, we provide insights into the ClimateStance and ClimateReddit using part-of-speech tagging and named-entity recognition.",
|
130 |
+
}
|
131 |
+
}"""
|
132 |
+
),
|
133 |
+
url="https://github.com/roopalv54/finegrained-climate-change-social-media",
|
134 |
+
),
|
135 |
+
ClimaBenchConfig(
|
136 |
+
name="climate_eng",
|
137 |
+
description=textwrap.dedent(
|
138 |
+
"""\
|
139 |
+
With climate change becoming a cause of concern worldwide, it becomes essential to gauge people{'}s reactions. This can help educate and spread awareness about it and help leaders improve decision-making. This work explores the fine-grained classification and Stance detection of climate change-related social media text. Firstly, we create two datasets, ClimateStance and ClimateEng, consisting of 3777 tweets each, posted during the 2019 United Nations Framework Convention on Climate Change and comprehensively outline the dataset collection, annotation methodology, and dataset composition. Secondly, we propose the task of Climate Change stance detection based on our proposed ClimateStance dataset. Thirdly, we propose a fine-grained classification based on the ClimateEng dataset, classifying social media text into five categories: Disaster, Ocean/Water, Agriculture/Forestry, Politics, and General. We benchmark both the datasets for climate change stance detection and fine-grained classification using state-of-the-art methods in text classification. We also create a Reddit-based dataset for both the tasks, ClimateReddit, consisting of 6262 pseudo-labeled comments along with 329 manually annotated comments for the label. We then perform semi-supervised experiments for both the tasks and benchmark their results using the best-performing model for the supervised experiments. Lastly, we provide insights into the ClimateStance and ClimateReddit using part-of-speech tagging and named-entity recognition."""
|
140 |
+
),
|
141 |
+
text_features={"text": "text"},
|
142 |
+
label_classes=["0", "1", "2", "3", "4"],
|
143 |
+
label_column="label",
|
144 |
+
data_dir="all_data/ClimateEng",
|
145 |
+
citation=textwrap.dedent(
|
146 |
+
"""\
|
147 |
+
@inproceedings{vaid-etal-2022-towards,
|
148 |
+
title = "Towards Fine-grained Classification of Climate Change related Social Media Text",
|
149 |
+
author = "Vaid, Roopal and
|
150 |
+
Pant, Kartikey and
|
151 |
+
Shrivastava, Manish",
|
152 |
+
booktitle = "Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics: Student Research Workshop",
|
153 |
+
month = may,
|
154 |
+
year = "2022",
|
155 |
+
address = "Dublin, Ireland",
|
156 |
+
publisher = "Association for Computational Linguistics",
|
157 |
+
url = "https://aclanthology.org/2022.acl-srw.35",
|
158 |
+
doi = "10.18653/v1/2022.acl-srw.35",
|
159 |
+
pages = "434--443",
|
160 |
+
abstract = "With climate change becoming a cause of concern worldwide, it becomes essential to gauge people{'}s reactions. This can help educate and spread awareness about it and help leaders improve decision-making. This work explores the fine-grained classification and Stance detection of climate change-related social media text. Firstly, we create two datasets, ClimateStance and ClimateEng, consisting of 3777 tweets each, posted during the 2019 United Nations Framework Convention on Climate Change and comprehensively outline the dataset collection, annotation methodology, and dataset composition. Secondly, we propose the task of Climate Change stance detection based on our proposed ClimateStance dataset. Thirdly, we propose a fine-grained classification based on the ClimateEng dataset, classifying social media text into five categories: Disaster, Ocean/Water, Agriculture/Forestry, Politics, and General. We benchmark both the datasets for climate change stance detection and fine-grained classification using state-of-the-art methods in text classification. We also create a Reddit-based dataset for both the tasks, ClimateReddit, consisting of 6262 pseudo-labeled comments along with 329 manually annotated comments for the label. We then perform semi-supervised experiments for both the tasks and benchmark their results using the best-performing model for the supervised experiments. Lastly, we provide insights into the ClimateStance and ClimateReddit using part-of-speech tagging and named-entity recognition.",
|
161 |
+
}
|
162 |
+
}"""
|
163 |
+
),
|
164 |
+
url="https://github.com/roopalv54/finegrained-climate-change-social-media",
|
165 |
+
),
|
166 |
+
ClimaBenchConfig(
|
167 |
+
name="climate_fever",
|
168 |
+
description=textwrap.dedent(
|
169 |
+
"""\
|
170 |
+
A dataset adopting the FEVER methodology that consists of 1,535 real-world claims regarding climate-change collected on the internet. Each claim is accompanied by five manually annotated evidence sentences retrieved from the English Wikipedia that support, refute or do not give enough information to validate the claim totalling in 7,675 claim-evidence pairs. The dataset features challenging claims that relate multiple facets and disputed cases of claims where both supporting and refuting evidence are present."""
|
171 |
+
),
|
172 |
+
data_dir="all_data/ClimateFEVER/test-data",
|
173 |
+
citation=textwrap.dedent(
|
174 |
+
"""\
|
175 |
+
@misc{diggelmann2020climatefever,
|
176 |
+
title={CLIMATE-FEVER: A Dataset for Verification of Real-World Climate Claims},
|
177 |
+
author={Thomas Diggelmann and Jordan Boyd-Graber and Jannis Bulian and Massimiliano Ciaramita and Markus Leippold},
|
178 |
+
year={2020},
|
179 |
+
eprint={2012.00614},
|
180 |
+
archivePrefix={arXiv},
|
181 |
+
primaryClass={cs.CL}
|
182 |
+
}
|
183 |
+
}"""
|
184 |
+
),
|
185 |
+
url="http://climatefever.ai",
|
186 |
+
),
|
187 |
+
ClimaBenchConfig(
|
188 |
+
name="climatext",
|
189 |
+
description=textwrap.dedent(
|
190 |
+
"""\
|
191 |
+
Climatext is a dataset for sentence-based climate change topic detection. The dataset explores different approaches to identify the climate change topic in various text sources"""
|
192 |
+
),
|
193 |
+
text_features={"text": "sentence"},
|
194 |
+
label_classes=["0", "1", "2", "3", "4"],
|
195 |
+
label_column="label",
|
196 |
+
data_dir="all_data/ClimaText",
|
197 |
+
citation=textwrap.dedent(
|
198 |
+
"""\
|
199 |
+
@misc{varini2021climatext,
|
200 |
+
title={ClimaText: A Dataset for Climate Change Topic Detection},
|
201 |
+
author={Francesco S. Varini and Jordan Boyd-Graber and Massimiliano Ciaramita and Markus Leippold},
|
202 |
+
year={2021},
|
203 |
+
eprint={2012.00483},
|
204 |
+
archivePrefix={arXiv},
|
205 |
+
primaryClass={cs.CL}
|
206 |
+
}
|
207 |
+
}"""
|
208 |
+
),
|
209 |
+
url="https://www.sustainablefinance.uzh.ch/en/research/climate-fever/climatext.html",
|
210 |
+
),
|
211 |
+
ClimaBenchConfig(
|
212 |
+
name="clima_insurance",
|
213 |
+
description=textwrap.dedent(
|
214 |
+
"""\
|
215 |
+
We create two tasks based on the responses to the NAIC survey, first being a binary Yes/No classification task
|
216 |
+
(CLIMA-INSURANCE) and the other one being a question type classification problem (CLIMAINSURANCE+).
|
217 |
+
The data is web scraped from all the annual survey responses between 2012-2021 giving a total of 17K labelled passages.
|
218 |
+
We remove the first sentence in each response as it contains obvious markers (like "Yes, we do X." or "No, we do not participate in Y.") and create splits for training, validation and testing.
|
219 |
+
The splits of the two datasets are different since we stratify by the class label in order to fairly balance the classes across the splits."""
|
220 |
+
),
|
221 |
+
label_classes=["0", "1"],
|
222 |
+
data_dir="all_data/ClimateInsurance",
|
223 |
+
text_features={"text": "text"},
|
224 |
+
label_column="label",
|
225 |
+
**_CLIMABENCH_BASE_KWARGS,
|
226 |
+
),
|
227 |
+
ClimaBenchConfig(
|
228 |
+
name="clima_insurance_plus",
|
229 |
+
description=textwrap.dedent(
|
230 |
+
"""\
|
231 |
+
We create two tasks based on the responses to the NAIC survey, first being a binary Yes/No classification task
|
232 |
+
(CLIMA-INSURANCE) and the other one being a question type classification problem (CLIMAINSURANCE+).
|
233 |
+
The data is web scraped from all the annual survey responses between 2012-2021 giving a total of 17K labelled passages.
|
234 |
+
We remove the first sentence in each response as it contains obvious markers (like "Yes, we do X." or "No, we do not participate in Y.") and create splits for training, validation and testing.
|
235 |
+
The splits of the two datasets are different since we stratify by the class label in order to fairly balance the classes across the splits."""
|
236 |
+
),
|
237 |
+
label_classes=["0", "1", "2", "3", "4", "5", "6", "7"],
|
238 |
+
data_dir="all_data/ClimateInsuranceMulti",
|
239 |
+
text_features={"text": "text"},
|
240 |
+
label_column="label",
|
241 |
+
**_CLIMABENCH_BASE_KWARGS,
|
242 |
+
),
|
243 |
+
ClimaBenchConfig(
|
244 |
+
name="clima_cdp",
|
245 |
+
description=textwrap.dedent(
|
246 |
+
"""\
|
247 |
+
The CDP survey responses fall into 3 buckets, namely Cities, States and Corporations, each with a different questionnaire with varying number of questions.
|
248 |
+
We filter out non-English, short (less than 10 words) and duplicate responses. The Cities dataset is the largest by volume and
|
249 |
+
consists of parent sections and subsections. We transform these sections into 12 broad categories
|
250 |
+
with the help of our climate change researcher to curate the labelled data called CLIMA-CDP for the
|
251 |
+
years 2018-2021 (Appendix Table 8). The goal is to classify CC data into relevant categories. The
|
252 |
+
12-category mapping creates a more parsimonious set of labels which can be compared to other studies and reduces noise in classification (The original
|
253 |
+
CDP section labels have changed slightly in the period 2018-2021). The train, development and
|
254 |
+
test splits are stratified by the organization so that some organization responses are not seen during
|
255 |
+
training."""
|
256 |
+
),
|
257 |
+
label_classes=[
|
258 |
+
"Emissions",
|
259 |
+
"Strategy",
|
260 |
+
"Climate Hazards",
|
261 |
+
"Governance and Data Management",
|
262 |
+
"Opportunities",
|
263 |
+
"Adaptation",
|
264 |
+
"Water",
|
265 |
+
"Energy",
|
266 |
+
"Waste",
|
267 |
+
"Transport",
|
268 |
+
"Food",
|
269 |
+
"Buildings",
|
270 |
+
],
|
271 |
+
data_dir="all_data/CDP/Cities/Cities Responses",
|
272 |
+
text_features={"text": "Text"},
|
273 |
+
label_column="Label",
|
274 |
+
**_CLIMABENCH_BASE_KWARGS,
|
275 |
+
),
|
276 |
+
ClimaBenchConfig(
|
277 |
+
name="clima_qa",
|
278 |
+
description=textwrap.dedent(
|
279 |
+
"""\
|
280 |
+
Although the categories in CLIMACDP are valuable for CC topic classification, they
|
281 |
+
restrict the downstream application to finite classes.
|
282 |
+
Hence, we extend our focus on the actual question
|
283 |
+
response pairs within the surveys to set up a more
|
284 |
+
nuanced and challenging QA dataset called CLIMAQA. The pre-processing steps are the
|
285 |
+
same as that of CLIMA-CDP. We curate three different subsets: CDP-CITIES, CDP-STATES and
|
286 |
+
CDP-CORPORATION where the splits
|
287 |
+
are stratified by the organizations. They have 294,
|
288 |
+
132 and 43 unique questions respectively."""
|
289 |
+
),
|
290 |
+
data_dir="all_data/CDP",
|
291 |
+
text_features={"question": "question", "answer": "answer"},
|
292 |
+
label_classes=["0", "1"],
|
293 |
+
label_column="label",
|
294 |
+
**_CLIMABENCH_BASE_KWARGS,
|
295 |
+
),
|
296 |
+
]
|
297 |
+
|
298 |
+
def _info(self):
|
299 |
+
if self.config.name == "climate_fever":
|
300 |
+
features = datasets.Features(
|
301 |
+
{
|
302 |
+
"claim_id": datasets.Value("string"),
|
303 |
+
"claim": datasets.Value("string"),
|
304 |
+
"claim_label": datasets.ClassLabel(
|
305 |
+
names=["SUPPORTS", "REFUTES", "NOT_ENOUGH_INFO", "DISPUTED"]
|
306 |
+
),
|
307 |
+
"evidences": [
|
308 |
+
{
|
309 |
+
"evidence_id": datasets.Value("string"),
|
310 |
+
"evidence_label": datasets.ClassLabel(
|
311 |
+
names=["SUPPORTS", "REFUTES", "NOT_ENOUGH_INFO"]
|
312 |
+
),
|
313 |
+
"article": datasets.Value("string"),
|
314 |
+
"evidence": datasets.Value("string"),
|
315 |
+
"entropy": datasets.Value("float32"),
|
316 |
+
"votes": [datasets.Value("string")],
|
317 |
+
},
|
318 |
+
],
|
319 |
+
}
|
320 |
+
)
|
321 |
+
else:
|
322 |
+
if self.config.name == "clima_qa":
|
323 |
+
features = {
|
324 |
+
text_feature: datasets.Value("string")
|
325 |
+
for text_feature in self.config.text_features.keys()
|
326 |
+
}
|
327 |
+
features["category"] = datasets.Value("string")
|
328 |
+
else:
|
329 |
+
features = {
|
330 |
+
text_feature: datasets.Value("string")
|
331 |
+
for text_feature in self.config.text_features.keys()
|
332 |
+
}
|
333 |
+
if self.config.label_classes:
|
334 |
+
features["label"] = datasets.features.ClassLabel(
|
335 |
+
names=self.config.label_classes
|
336 |
+
)
|
337 |
+
else:
|
338 |
+
features["label"] = datasets.Value("float32")
|
339 |
+
features["idx"] = datasets.Value("int32")
|
340 |
+
return datasets.DatasetInfo(
|
341 |
+
description=_DESCRIPTION,
|
342 |
+
features=datasets.Features(features),
|
343 |
+
homepage=self.config.url,
|
344 |
+
citation=self.config.citation + "\n" + _CITATION,
|
345 |
+
)
|
346 |
+
|
347 |
+
def _split_generators(self, dl_manager):
|
348 |
+
dl_dir = dl_manager.download_and_extract(_URL)
|
349 |
+
data_dir = os.path.join(dl_dir, self.config.data_dir)
|
350 |
+
|
351 |
+
if self.config.name == "climate_fever":
|
352 |
+
return [
|
353 |
+
datasets.SplitGenerator(
|
354 |
+
name=datasets.Split.TEST,
|
355 |
+
gen_kwargs={
|
356 |
+
"data_file": os.path.join(
|
357 |
+
data_dir or "", "climate-fever-dataset-r1.jsonl"
|
358 |
+
),
|
359 |
+
"split": "test",
|
360 |
+
},
|
361 |
+
),
|
362 |
+
]
|
363 |
+
|
364 |
+
if self.config.name == "climatext":
|
365 |
+
files = {
|
366 |
+
"train": [
|
367 |
+
"train-data/AL-10Ks.tsv : 3000 (58 positives, 2942 negatives) (TSV, 127138 KB).tsv",
|
368 |
+
"train-data/AL-Wiki (train).tsv",
|
369 |
+
],
|
370 |
+
"valid": ["dev-data/Wikipedia (dev).tsv"],
|
371 |
+
"test": [
|
372 |
+
"test-data/Claims (test).tsv",
|
373 |
+
"test-data/Wikipedia (test).tsv",
|
374 |
+
"test-data/10-Ks (2018, test).tsv",
|
375 |
+
],
|
376 |
+
}
|
377 |
+
return [
|
378 |
+
datasets.SplitGenerator(
|
379 |
+
name=datasets.Split.TRAIN,
|
380 |
+
gen_kwargs={
|
381 |
+
"data_file": [
|
382 |
+
os.path.join(data_dir or "", f) for f in files["train"]
|
383 |
+
],
|
384 |
+
"split": "train",
|
385 |
+
},
|
386 |
+
),
|
387 |
+
datasets.SplitGenerator(
|
388 |
+
name=datasets.Split.VALIDATION,
|
389 |
+
gen_kwargs={
|
390 |
+
"data_file": [
|
391 |
+
os.path.join(data_dir or "", f) for f in files["valid"]
|
392 |
+
],
|
393 |
+
"split": "valid",
|
394 |
+
},
|
395 |
+
),
|
396 |
+
datasets.SplitGenerator(
|
397 |
+
name=datasets.Split.TEST,
|
398 |
+
gen_kwargs={
|
399 |
+
"data_file": [
|
400 |
+
os.path.join(data_dir or "", f) for f in files["test"]
|
401 |
+
],
|
402 |
+
"split": "test",
|
403 |
+
},
|
404 |
+
),
|
405 |
+
]
|
406 |
+
|
407 |
+
if self.config.name == "clima_qa":
|
408 |
+
categories = {
|
409 |
+
"cities": "Cities/Cities Responses",
|
410 |
+
"states": "States",
|
411 |
+
"corporations": "Corporations/Corporations Responses/Climate Change",
|
412 |
+
}
|
413 |
+
return [
|
414 |
+
datasets.SplitGenerator(
|
415 |
+
name=datasets.Split.TRAIN,
|
416 |
+
gen_kwargs={
|
417 |
+
"data_file": [
|
418 |
+
(k, os.path.join(data_dir or "", v, "train_qa.csv"))
|
419 |
+
for k, v in categories.items()
|
420 |
+
],
|
421 |
+
"split": "train",
|
422 |
+
},
|
423 |
+
),
|
424 |
+
datasets.SplitGenerator(
|
425 |
+
name=datasets.Split.VALIDATION,
|
426 |
+
gen_kwargs={
|
427 |
+
"data_file": [
|
428 |
+
(k, os.path.join(data_dir or "", v, "val_qa.csv"))
|
429 |
+
for k, v in categories.items()
|
430 |
+
],
|
431 |
+
"split": "valid",
|
432 |
+
},
|
433 |
+
),
|
434 |
+
datasets.SplitGenerator(
|
435 |
+
name=datasets.Split.TEST,
|
436 |
+
gen_kwargs={
|
437 |
+
"data_file": [
|
438 |
+
(k, os.path.join(data_dir or "", v, "test_qa.csv"))
|
439 |
+
for k, v in categories.items()
|
440 |
+
],
|
441 |
+
"split": "test",
|
442 |
+
},
|
443 |
+
),
|
444 |
+
]
|
445 |
+
|
446 |
+
return [
|
447 |
+
datasets.SplitGenerator(
|
448 |
+
name=datasets.Split.TRAIN,
|
449 |
+
gen_kwargs={
|
450 |
+
"data_file": os.path.join(data_dir or "", "train.csv"),
|
451 |
+
"split": "train",
|
452 |
+
},
|
453 |
+
),
|
454 |
+
datasets.SplitGenerator(
|
455 |
+
name=datasets.Split.VALIDATION,
|
456 |
+
gen_kwargs={
|
457 |
+
"data_file": os.path.join(data_dir or "", "val.csv"),
|
458 |
+
"split": "valid",
|
459 |
+
},
|
460 |
+
),
|
461 |
+
datasets.SplitGenerator(
|
462 |
+
name=datasets.Split.TEST,
|
463 |
+
gen_kwargs={
|
464 |
+
"data_file": os.path.join(data_dir or "", "test.csv"),
|
465 |
+
"split": "test",
|
466 |
+
},
|
467 |
+
),
|
468 |
+
]
|
469 |
+
|
470 |
+
def _generate_examples(self, data_file, split):
|
471 |
+
if self.config.name == "climate_fever":
|
472 |
+
with open(data_file, encoding="utf-8") as f:
|
473 |
+
for id_, row in enumerate(f):
|
474 |
+
doc = json.loads(row)
|
475 |
+
yield id_, doc
|
476 |
+
elif self.config.name == "climatext":
|
477 |
+
idx = iter(range(100000))
|
478 |
+
for file in data_file:
|
479 |
+
yield from self._process_file(file, delimiter="\t", idx=idx)
|
480 |
+
elif self.config.name == "clima_qa":
|
481 |
+
idx = iter(range(10000000))
|
482 |
+
for category, file in data_file:
|
483 |
+
yield from self._process_file(file, idx=idx, category=category)
|
484 |
+
else:
|
485 |
+
yield from self._process_file(data_file)
|
486 |
+
|
487 |
+
def _process_file(self, data_file, delimiter=",", idx=None, category=None):
|
488 |
+
with open(data_file, encoding="utf8") as f:
|
489 |
+
process_label = self.config.process_label
|
490 |
+
label_classes = self.config.label_classes
|
491 |
+
reader = csv.DictReader(f, delimiter=delimiter, quoting=csv.QUOTE_ALL)
|
492 |
+
for n, row in enumerate(reader):
|
493 |
+
example = {
|
494 |
+
feat: row[col] for feat, col in self.config.text_features.items()
|
495 |
+
}
|
496 |
+
if idx:
|
497 |
+
example["idx"] = next(idx)
|
498 |
+
else:
|
499 |
+
example["idx"] = n
|
500 |
+
|
501 |
+
if category:
|
502 |
+
example["category"] = category
|
503 |
+
|
504 |
+
if self.config.label_column in row:
|
505 |
+
label = row[self.config.label_column]
|
506 |
+
# For some tasks, the label is represented as 0 and 1 in the tsv
|
507 |
+
# files and needs to be cast to integer to work with the feature.
|
508 |
+
if label_classes and label not in label_classes:
|
509 |
+
label = int(label) if label else None
|
510 |
+
example["label"] = process_label(label)
|
511 |
+
else:
|
512 |
+
example["label"] = process_label(-1)
|
513 |
+
|
514 |
+
# Filter out corrupted rows.
|
515 |
+
for value in example.values():
|
516 |
+
if value is None:
|
517 |
+
break
|
518 |
+
else:
|
519 |
+
yield example["idx"], example
|