heliumind commited on
Commit
4164689
·
1 Parent(s): 74ce785

add dataset loading script

Browse files
Files changed (1) hide show
  1. clef_ehealth_2019.py +110 -0
clef_ehealth_2019.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2025 Henry He.
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
+ import datasets
17
+ import csv
18
+
19
+ _CITATION = """\
20
+ @Misc{openagrar_mods_00046540,
21
+ author = {Neves, Mariana
22
+ and Butzke, Daniel
23
+ and D{\"o}rendahl, Antje
24
+ and Leich, Nora
25
+ and Grune, Barbara
26
+ and Sch{\"o}nfelder, Gilbert},
27
+ title = {Non-technical Summaries (NTS) of Animal Experiments Indexed with ICD-10 Codes (Version 1.0)},
28
+ year = {2019},
29
+ month = {Jan},
30
+ day = {18},
31
+ publisher = {Open Agrar Repository},
32
+ keywords = {animal experiment; non-technical summaries; ICD-10 codes; text mining; document indexing; Deutschland},
33
+ abstract = {Dataset containing 8,386 non-technical summaries (NTS) of animal experiments recently carried out in Germany (as of September 19, 2018) and originally on-line available at the AnimalTestInfo database (http://animaltestinfo.de). Each NTS contains a title, uses (goals) of the experiments, possible harms caused to the animals, and comments about replacement, reduction and refinement (in the scope of the 3R principles). All documents are in the German language. The dataset includes the ICD-10 codes manually assigned by experts to the NTS. However, some NTSs have no ICD-10 codes assigned to them, as the codes were not applicable to the uses described in the NTS. All codes are chapters or groups from the ICD-10 German Modification 2016 version (https://www.dimdi.de/static/de/klassifikationen/icd/icd-10-gm/kode-suche/htmlgm2016/). Finally, the dataset is split into training and development datasets which are meant to be used in the CLEF eHealth 2019, Task 1 - Multilingual Information Extraction (https://sites.google.com/view/clefehealth2019/task-1-multilingual-information-extraction-icd10-coding).},
34
+ doi = {10.17590/20190118-134645-0},
35
+ url = {https://www.openagrar.de/receive/openagrar_mods_00046540},
36
+ url = {https://doi.org/10.17590/20190118-134645-0},
37
+ file = {:https://www.openagrar.de/servlets/MCRFileNodeServlet/openagrar_derivate_00019621/nts-icd.zip:TYPE},
38
+ language = {en}
39
+ }
40
+ """
41
+
42
+ _DESCRIPTION = """\
43
+ Dataset containing 8,386 non-technical summaries (NTS) of animal experiments recently carried out in Germany (as of September 19, 2018) and originally on-line available at the AnimalTestInfo database (http://animaltestinfo.de). Each NTS contains a title, uses (goals) of the experiments, possible harms caused to the animals, and comments about replacement, reduction and refinement (in the scope of the 3R principles). All documents are in the German language. The dataset includes the ICD-10 codes manually assigned by experts to the NTS. However, some NTSs have no ICD-10 codes assigned to them, as the codes were not applicable to the uses described in the NTS. All codes are chapters or groups from the ICD-10 German Modification 2016 version (https://www.dimdi.de/static/de/klassifikationen/icd/icd-10-gm/kode-suche/htmlgm2016/). Finally, the dataset is split into training and development datasets which are meant to be used in the CLEF eHealth 2019, Task 1 - Multilingual Information Extraction (https://sites.google.com/view/clefehealth2019/task-1-multilingual-information-extraction-icd10-coding).
44
+ """
45
+
46
+ _HOMEPAGE = "https://www.openagrar.de/receive/openagrar_mods_00046540"
47
+
48
+ _URLS = {
49
+ "train": "data/train.csv",
50
+ "validation": "data/validation.csv",
51
+ "test": "data/test.csv"
52
+ }
53
+
54
+ _LICENSE = "apache-2.0"
55
+ _LANGUAGES = ["German"]
56
+ _VERSION = "1.0"
57
+
58
+ class CLEFeHealth2019(datasets.GeneratorBasedBuilder):
59
+ """CLEF eHealth 2019 Task 1. Version 1.0."""
60
+
61
+ def _info(self):
62
+ features = datasets.Features({
63
+ "id": datasets.Value("string"),
64
+ "title": datasets.Value("string"),
65
+ "goals": datasets.Value("string"),
66
+ "harms": datasets.Value("string"),
67
+ "replacement": datasets.Value("string"),
68
+ "reduction": datasets.Value("string"),
69
+ "refinement": datasets.Value("string"),
70
+ "labels": datasets.Sequence(datasets.Value("string")),
71
+ })
72
+ return datasets.DatasetInfo(
73
+ description=_DESCRIPTION,
74
+ features=features,
75
+ homepage=_HOMEPAGE,
76
+ license=_LICENSE,
77
+ citation=_CITATION,
78
+ )
79
+
80
+ def _split_generators(self, dl_manager):
81
+ downloaded_files = dl_manager.download(_URLS)
82
+ return [
83
+ datasets.SplitGenerator(
84
+ name=datasets.Split.TRAIN,
85
+ gen_kwargs={"filepath": downloaded_files["train"]},
86
+ ),
87
+ datasets.SplitGenerator(
88
+ name=datasets.Split.VALIDATION,
89
+ gen_kwargs={"filepath": downloaded_files["validation"]},
90
+ ),
91
+ datasets.SplitGenerator(
92
+ name=datasets.Split.TEST,
93
+ gen_kwargs={"filepath": downloaded_files["test"]},
94
+ ),
95
+ ]
96
+
97
+ def _generate_examples(self, filepath):
98
+ with open(filepath, encoding="utf-8") as f:
99
+ reader = csv.DictReader(f)
100
+ for id_, row in enumerate(reader):
101
+ yield id_, {
102
+ "id": row["id"],
103
+ "title": row["title"],
104
+ "goals": row["goals"],
105
+ "harms": row["harms"],
106
+ "replacement": row["replacement"],
107
+ "reduction": row["reduction"],
108
+ "refinement": row["refinement"],
109
+ "labels": row["labels"].split("|"),
110
+ }