File size: 6,568 Bytes
41a857c a91d107 41a857c 74c2992 41a857c a91d107 41a857c 4946933 41a857c 6a0aa6c 41a857c 4877edf |
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 |
# 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.
"""DIAMED"""
import os
import json
import math
import datasets
_DESCRIPTION = """\
DIAMED
"""
_HOMEPAGE = "DIAMED"
_LICENSE = "Apache License 2.0"
_URL = "https://huggingface.co/datasets/Dr-BERT/DiaMED/resolve/main/data.zip"
_CITATION = """\
DIAMED
"""
class DiaMed(datasets.GeneratorBasedBuilder):
"""DIAMED"""
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(name=f"default", version="1.0.0", description=f"DiaMED data"),
]
DEFAULT_CONFIG_NAME = "default"
def _info(self):
features = datasets.Features(
{
"identifier": datasets.Value("string"),
"title": datasets.Value("string"),
"clinical_case": datasets.Value("string"),
"topic": datasets.Value("string"),
"keywords": datasets.Sequence(
datasets.Value("string"),
),
"domains": datasets.Sequence(
datasets.Value("string"),
),
"collected_at": datasets.Value("string"),
"published_at": datasets.Value("string"),
"source_url": datasets.Value("string"),
"source_name": datasets.Value("string"),
"license": datasets.Value("string"),
"figures_urls": datasets.Sequence(
datasets.Value("string"),
),
"figures_paths": datasets.Sequence(
datasets.Value("string"),
),
"figures": datasets.Sequence(
datasets.Image(),
),
"icd-10": datasets.features.ClassLabel(names=[
'A00-B99 Certain infectious and parasitic diseases',
'C00-D49 Neoplasms',
'D50-D89 Diseases of the blood and blood-forming organs and certain disorders involving the immune mechanism',
'E00-E89 Endocrine, nutritional and metabolic diseases',
'F01-F99 Mental, Behavioral and Neurodevelopmental disorders',
'G00-G99 Diseases of the nervous system',
'H00-H59 Diseases of the eye and adnexa',
'H60-H95 Diseases of the ear and mastoid process',
'I00-I99 Diseases of the circulatory system',
'J00-J99 Diseases of the respiratory system',
'K00-K95 Diseases of the digestive system',
'L00-L99 Diseases of the skin and subcutaneous tissue',
'M00-M99 Diseases of the musculoskeletal system and connective tissue',
'N00-N99 Diseases of the genitourinary system',
'O00-O9A Pregnancy, childbirth and the puerperium',
'P00-P96 Certain conditions originating in the perinatal period',
'Q00-Q99 Congenital malformations, deformations and chromosomal abnormalities',
'R00-R99 Symptoms, signs and abnormal clinical and laboratory findings, not elsewhere classified',
'S00-T88 Injury, poisoning and certain other consequences of external causes',
'U00-U85 Codes for special purposes',
'V00-Y99 External causes of morbidity',
'Z00-Z99 Factors influencing health status and contact with health services',
]),
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
data_dir = dl_manager.download_and_extract(_URL)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"base_path": data_dir,
"filepath": data_dir + "/splits/train.json",
},
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
gen_kwargs={
"base_path": data_dir,
"filepath": data_dir + "/splits/validation.json",
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"base_path": data_dir,
"filepath": data_dir + "/splits/test.json",
},
),
]
def _generate_examples(self, base_path, filepath):
with open(filepath, encoding="utf-8") as f:
data = json.load(f)
for key, d in enumerate(data):
if str(d["icd-10"]) == "nan" or d["icd-10"].find("Plusieurs cas cliniques") != -1 or d["icd-10"].find("Aucune annotation") != -1:
continue
yield key, {
"identifier": d["identifier"],
"title": d["title"],
"clinical_case": d["clinical_case"],
"topic": d["topic"],
"keywords": d["keywords"],
"domains": d["domain"],
"collected_at": d["collected_at"],
"published_at": d["published_at"],
"source_url": d["source_url"],
"source_name": d["source_name"],
"license": d["license"],
"figures_urls": d["figures"],
"figures": [base_path + fg.lstrip(".") for fg in d["local_figures"]],
"figures_paths": [base_path + fg.lstrip(".") for fg in d["local_figures"]],
"icd-10": d["icd-10"],
}
|