Datasets:
File size: 12,700 Bytes
f64bc27 2e41bb6 15600b5 e3342b7 f64bc27 e3342b7 2e41bb6 e3342b7 f64bc27 e3342b7 f64bc27 e3342b7 f64bc27 8d4e8c1 f64bc27 e3342b7 f64bc27 eac6b07 f64bc27 405a4a9 f64bc27 e3342b7 f64bc27 472d22c f64bc27 472d22c 8d4e8c1 c8de64c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# coding=utf-8
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""HumSet: Dataset of Multilingual Information Extraction and Classification for Humanitarian Crisis Response"""
import json
import datasets
_CITATION = """\
@misc{https://doi.org/10.48550/arxiv.2210.04573,
doi = {10.48550/ARXIV.2210.04573},
url = {https://arxiv.org/abs/2210.04573},
author = {Fekih, Selim and Tamagnone, Nicolò and Minixhofer, Benjamin and Shrestha, Ranjan and Contla, Ximena and Oglethorpe, Ewan and Rekabsaz, Navid},
keywords = {Computation and Language (cs.CL), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {HumSet: Dataset of Multilingual Information Extraction and Classification for Humanitarian Crisis Response},
publisher = {arXiv},
year = {2022},
copyright = {arXiv.org perpetual, non-exclusive license}
}
"""
_DESCRIPTION = """\
HumSet is a novel and rich multilingual dataset of humanitarian response documents annotated by experts in the humanitarian response community. HumSet is curated by humanitarian analysts and covers various disasters around the globe that occurred from 2018 to 2021 in 46 humanitarian response projects. The dataset consists of approximately 17K annotated documents in three languages of English, French, and Spanish, originally taken from publicly-available resources. For each document, analysts have identified informative snippets (entries) in respect to common humanitarian frameworks, and assigned one or many classes to each entry. See the our paper for details.
"""
_HOMEPAGE = "https://huggingface.co/datasets/nlp-thedeep/humset"
_LICENSE = "The GitHub repository which houses this dataset has an Apache License 2.0."
_URLs = {
"1.0.0": {
"train": "data/train.jsonl",
"dev": "data/validation.jsonl",
"test": "data/test.jsonl",
},
"2.0.0": {
"train": "data/train_1_1.jsonl",
"dev": "data/validation_1_1_.jsonl",
"test": "data/test_1_1.jsonl"
}
}
_SUPPORTED_VERSIONS = [
# First version
datasets.Version("1.0.0", "Only primary tags"),
# Second version
datasets.Version("2.0.0", "Extented data points including secondary tags and geolocations"),
]
DEFAULT_CONFIG_NAME = "2.0.0"
## COMMON FEATURES
FIRST_FEATURES = datasets.Features(
{
"entry_id": datasets.Value("string"),
"lead_id": datasets.Value("string"),
"project_id": datasets.Value("string"),
"lang": datasets.Value("string"),
"n_tokens": datasets.Value("int64"),
"project_title": datasets.Value("string"),
"created_at": datasets.Value("string"),
"document": datasets.Value("string"),
"excerpt": datasets.Value("string"),
"sectors": datasets.Sequence(
feature=datasets.ClassLabel(
names=[
'Agriculture',
'Cross',
'Education',
'Food Security',
'Health',
'Livelihoods',
'Logistics',
'Nutrition',
'Protection',
'Shelter',
'WASH'
]
)
),
"pillars_1d": datasets.Sequence(
feature=datasets.ClassLabel(
names=[
'Casualties',
'Context',
'Covid-19',
'Displacement',
'Humanitarian Access',
'Information And Communication',
'Shock/Event'
]
)
),
"pillars_2d": datasets.Sequence(
feature=datasets.ClassLabel(
names=[
'At Risk',
'Capacities & Response',
'Humanitarian Conditions',
'Impact',
'Priority Interventions',
'Priority Needs'
]
)
),
"subpillars_1d": datasets.Sequence(
feature=datasets.ClassLabel(
names=[
'Casualties->Dead',
'Casualties->Injured',
'Casualties->Missing',
'Context->Demography',
'Context->Economy',
'Context->Environment',
'Context->Legal & Policy',
'Context->Politics',
'Context->Security & Stability',
'Context->Socio Cultural',
'Covid-19->Cases',
'Covid-19->Contact Tracing',
'Covid-19->Deaths',
'Covid-19->Hospitalization & Care',
'Covid-19->Restriction Measures',
'Covid-19->Testing',
'Covid-19->Vaccination',
'Displacement->Intentions',
'Displacement->Local Integration',
'Displacement->Pull Factors',
'Displacement->Push Factors',
'Displacement->Type/Numbers/Movements',
'Humanitarian Access->Number Of People Facing Humanitarian Access Constraints/Humanitarian Access Gaps',
'Humanitarian Access->Physical Constraints',
'Humanitarian Access->Population To Relief',
'Humanitarian Access->Relief To Population',
'Information And Communication->Communication Means And Preferences',
'Information And Communication->Information Challenges And Barriers',
'Information And Communication->Knowledge And Info Gaps (Hum)',
'Information And Communication->Knowledge And Info Gaps (Pop)',
'Shock/Event->Hazard & Threats',
'Shock/Event->Type And Characteristics',
'Shock/Event->Underlying/Aggravating Factors'
]
)
),
"subpillars_2d": datasets.Sequence(
feature=datasets.ClassLabel(
names=[
'At Risk->Number Of People At Risk',
'At Risk->Risk And Vulnerabilities',
'Capacities & Response->International Response',
'Capacities & Response->Local Response',
'Capacities & Response->National Response',
'Capacities & Response->Number Of People Reached/Response Gaps',
'Humanitarian Conditions->Coping Mechanisms',
'Humanitarian Conditions->Living Standards',
'Humanitarian Conditions->Number Of People In Need',
'Humanitarian Conditions->Physical And Mental Well Being',
'Impact->Driver/Aggravating Factors',
'Impact->Impact On People',
'Impact->Impact On Systems, Services And Networks',
'Impact->Number Of People Affected',
'Priority Interventions->Expressed By Humanitarian Staff',
'Priority Interventions->Expressed By Population',
'Priority Needs->Expressed By Humanitarian Staff',
'Priority Needs->Expressed By Population'
]
)
)
}
)
"""
from: https://huggingface.co/docs/datasets/v2.9.0/en/package_reference/main_classes#datasets.Sequence
a python list or a Sequence specifies that the field contains a list of objects.
The python list or Sequence should be provided with a single sub-feature as an example of the feature type hosted in this list.
"""
SECOND_FEATURES = datasets.Features(
{
"entry_id": datasets.Value("string"),
"lead_id": datasets.Value("string"),
"lang": datasets.Value("string"),
"n_tokens": datasets.Value("int64"),
"project_title": datasets.Value("string"),
"created_at": datasets.Value("string"),
"document": datasets.Value("string"),
"source_title": datasets.Value("string"),
"author_title": datasets.Value("string"),
"excerpt": datasets.Value("string"),
"geo_location": datasets.Sequence(datasets.Value("string"), length=-1),
"sectors": datasets.Sequence(datasets.Value("string"), length=-1),
"pillars_1d": datasets.Sequence(datasets.Value("string"), length=-1),
"pillars_2d": datasets.Sequence(datasets.Value("string"), length=-1),
"subpillars_1d": datasets.Sequence(datasets.Value("string"), length=-1),
"subpillars_2d": datasets.Sequence(datasets.Value("string"), length=-1),
"displaced": datasets.Sequence(datasets.Value("string"), length=-1),
"non_displaced": datasets.Sequence(datasets.Value("string"), length=-1),
"affected": datasets.Sequence(datasets.Value("string"), length=-1),
"severity": datasets.Sequence(datasets.Value("string"), length=-1),
"age": datasets.Sequence(datasets.Value("string"), length=-1),
"gender": datasets.Sequence(datasets.Value("string"), length=-1),
"specific_needs_groups": datasets.Sequence(datasets.Value("string"), length=-1)
}
)
class HumsetConfig(datasets.BuilderConfig):
"""BuilderConfig for DuoRC SelfRC."""
def __init__(self, **kwargs):
"""BuilderConfig for DuoRC SelfRC.
Args:
**kwargs: keyword arguments forwarded to super.
"""
super(HumsetConfig, self).__init__(**kwargs)
class Humset(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
HumsetConfig(
name=str(version),
description=f"version {str(version)}",
version=version
)
for version in _SUPPORTED_VERSIONS
]
def _info(self):
if self.config.name == "1.0.0":
return datasets.DatasetInfo(
# This is the description that will appear on the datasets page.
description=_DESCRIPTION,
# This defines the different columns of the dataset and their types
features=FIRST_FEATURES,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
elif self.config.name == "2.0.0":
return datasets.DatasetInfo(
# This is the description that will appear on the datasets page.
description=_DESCRIPTION,
# This defines the different columns of the dataset and their types
features=SECOND_FEATURES,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
my_urls = _URLs[self.config.name]
downloaded_files = dl_manager.download_and_extract(my_urls)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"filepath": downloaded_files["train"],
},
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
gen_kwargs={
"filepath": downloaded_files["dev"],
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"filepath": downloaded_files["test"],
},
),
]
def _generate_examples(self, filepath):
"""This function returns the examples in the raw (text) form."""
with open(filepath, encoding="utf-8") as f:
data = list(f)
idx = 0
for line in data:
row = json.loads(line)
#if self.config.name == "1.0.0":
yield idx, row
idx+=1
|