Upload 2 files
Browse files
README.md
CHANGED
|
@@ -1,84 +1,86 @@
|
|
| 1 |
---
|
| 2 |
dataset_info:
|
| 3 |
features:
|
| 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 |
config_name: e3c
|
| 34 |
splits:
|
| 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 |
download_size: 230213492
|
| 81 |
-
dataset_size:
|
| 82 |
---
|
| 83 |
|
| 84 |
# Dataset Card for E3C
|
|
@@ -107,4 +109,4 @@ information about clinical entities based on medical taxonomies, to be used for
|
|
| 107 |
url = {https://uts.nlm.nih.gov/uts/umls/home},
|
| 108 |
year = {2021},
|
| 109 |
}
|
| 110 |
-
```
|
|
|
|
| 1 |
---
|
| 2 |
dataset_info:
|
| 3 |
features:
|
| 4 |
+
- name: text
|
| 5 |
+
dtype: string
|
| 6 |
+
- name: tokens
|
| 7 |
+
sequence: string
|
| 8 |
+
- name: tokens_offsets
|
| 9 |
+
sequence:
|
| 10 |
+
sequence: int32
|
| 11 |
+
- name: clinical_entity_tags
|
| 12 |
+
sequence:
|
| 13 |
+
class_label:
|
| 14 |
+
names:
|
| 15 |
+
'0': O
|
| 16 |
+
'1': B-CLINENTITY
|
| 17 |
+
'2': I-CLINENTITY
|
| 18 |
+
- name: clinical_entity_cuid
|
| 19 |
+
sequence: string
|
| 20 |
+
- name: temporal_information_tags
|
| 21 |
+
sequence:
|
| 22 |
+
class_label:
|
| 23 |
+
names:
|
| 24 |
+
'0': O
|
| 25 |
+
'1': B-EVENT
|
| 26 |
+
'2': B-ACTOR
|
| 27 |
+
'3': B-BODYPART
|
| 28 |
+
'4': B-TIMEX3
|
| 29 |
+
'5': B-RML
|
| 30 |
+
'6': I-EVENT
|
| 31 |
+
'7': I-ACTOR
|
| 32 |
+
'8': I-BODYPART
|
| 33 |
+
'9': I-TIMEX3
|
| 34 |
+
'10': I-RML
|
| 35 |
config_name: e3c
|
| 36 |
splits:
|
| 37 |
+
- name: en.layer1
|
| 38 |
+
num_bytes: 1632165
|
| 39 |
+
num_examples: 1520
|
| 40 |
+
- name: en.layer2
|
| 41 |
+
num_bytes: 3263885
|
| 42 |
+
num_examples: 2873
|
| 43 |
+
- name: en.layer2.validation
|
| 44 |
+
num_bytes: 371196
|
| 45 |
+
num_examples: 334
|
| 46 |
+
- name: es.layer1
|
| 47 |
+
num_bytes: 1599169
|
| 48 |
+
num_examples: 1134
|
| 49 |
+
- name: es.layer2
|
| 50 |
+
num_bytes: 3192361
|
| 51 |
+
num_examples: 2347
|
| 52 |
+
- name: es.layer2.validation
|
| 53 |
+
num_bytes: 352193
|
| 54 |
+
num_examples: 261
|
| 55 |
+
- name: eu.layer1
|
| 56 |
+
num_bytes: 1931109
|
| 57 |
+
num_examples: 3126
|
| 58 |
+
- name: eu.layer2
|
| 59 |
+
num_bytes: 1066405
|
| 60 |
+
num_examples: 1594
|
| 61 |
+
- name: eu.layer2.validation
|
| 62 |
+
num_bytes: 279306
|
| 63 |
+
num_examples: 468
|
| 64 |
+
- name: fr.layer1
|
| 65 |
+
num_bytes: 1610663
|
| 66 |
+
num_examples: 1109
|
| 67 |
+
- name: fr.layer2
|
| 68 |
+
num_bytes: 3358033
|
| 69 |
+
num_examples: 2389
|
| 70 |
+
- name: fr.layer2.validation
|
| 71 |
+
num_bytes: 361816
|
| 72 |
+
num_examples: 293
|
| 73 |
+
- name: it.layer1
|
| 74 |
+
num_bytes: 1633613
|
| 75 |
+
num_examples: 1146
|
| 76 |
+
- name: it.layer2
|
| 77 |
+
num_bytes: 3373977
|
| 78 |
+
num_examples: 2436
|
| 79 |
+
- name: it.layer2.validation
|
| 80 |
+
num_bytes: 366932
|
| 81 |
+
num_examples: 275
|
| 82 |
download_size: 230213492
|
| 83 |
+
dataset_size: 24392823
|
| 84 |
---
|
| 85 |
|
| 86 |
# Dataset Card for E3C
|
|
|
|
| 109 |
url = {https://uts.nlm.nih.gov/uts/umls/home},
|
| 110 |
year = {2021},
|
| 111 |
}
|
| 112 |
+
```
|
e3c.py
CHANGED
|
@@ -70,6 +70,9 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
| 70 |
],
|
| 71 |
),
|
| 72 |
),
|
|
|
|
|
|
|
|
|
|
| 73 |
"temporal_information_tags": datasets.Sequence(
|
| 74 |
datasets.features.ClassLabel(
|
| 75 |
names=[
|
|
@@ -285,6 +288,25 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
| 285 |
def get_annotations(entities: ResultSet, text: str) -> list:
|
| 286 |
"""Extract the offset, the text and the type of the entity.
|
| 287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
Args:
|
| 289 |
entities: The entities to extract.
|
| 290 |
text: The text of the document.
|
|
@@ -296,6 +318,7 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
| 296 |
int(entity.get("begin")),
|
| 297 |
int(entity.get("end")),
|
| 298 |
text[int(entity.get("begin")) : int(entity.get("end"))],
|
|
|
|
| 299 |
]
|
| 300 |
for entity in entities
|
| 301 |
]
|
|
@@ -320,7 +343,7 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
| 320 |
soup = BeautifulSoup(soup_file, "xml")
|
| 321 |
text = soup.find("cas:Sofa").get("sofaString")
|
| 322 |
yield {
|
| 323 |
-
"CLINENTITY": self.
|
| 324 |
soup.find_all("custom:CLINENTITY"), text
|
| 325 |
),
|
| 326 |
"EVENT": self.get_annotations(soup.find_all("custom:EVENT"), text),
|
|
@@ -362,6 +385,7 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
| 362 |
[token[0] - sentence[0], token[1] - sentence[0]] for token in filtered_tokens
|
| 363 |
]
|
| 364 |
clinical_labels = ["O"] * len(filtered_tokens)
|
|
|
|
| 365 |
temporal_information_labels = ["O"] * len(filtered_tokens)
|
| 366 |
for entity_type in [
|
| 367 |
"CLINENTITY",
|
|
@@ -386,6 +410,7 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
| 386 |
clinical_labels[idx_token] = f"B-{entity_type}"
|
| 387 |
else:
|
| 388 |
clinical_labels[idx_token] = f"I-{entity_type}"
|
|
|
|
| 389 |
else:
|
| 390 |
if idx_token == annotated_tokens[0]:
|
| 391 |
temporal_information_labels[idx_token] = f"B-{entity_type}"
|
|
@@ -395,7 +420,12 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
| 395 |
"text": sentence[-1],
|
| 396 |
"tokens": list(map(lambda token: token[2], filtered_tokens)),
|
| 397 |
"clinical_entity_tags": clinical_labels,
|
|
|
|
| 398 |
"temporal_information_tags": temporal_information_labels,
|
| 399 |
"tokens_offsets": tokens_offsets,
|
| 400 |
}
|
| 401 |
guid += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
],
|
| 71 |
),
|
| 72 |
),
|
| 73 |
+
"clinical_entity_cuid": datasets.Sequence(
|
| 74 |
+
datasets.Value("string"),
|
| 75 |
+
),
|
| 76 |
"temporal_information_tags": datasets.Sequence(
|
| 77 |
datasets.features.ClassLabel(
|
| 78 |
names=[
|
|
|
|
| 288 |
def get_annotations(entities: ResultSet, text: str) -> list:
|
| 289 |
"""Extract the offset, the text and the type of the entity.
|
| 290 |
|
| 291 |
+
Args:
|
| 292 |
+
entities: The entities to extract.
|
| 293 |
+
text: The text of the document.
|
| 294 |
+
Returns:
|
| 295 |
+
A list of list containing the offset, the text and the type of the entity.
|
| 296 |
+
"""
|
| 297 |
+
return [
|
| 298 |
+
|
| 299 |
+
[
|
| 300 |
+
int(entity.get("begin")),
|
| 301 |
+
int(entity.get("end")),
|
| 302 |
+
text[int(entity.get("begin")) : int(entity.get("end"))],
|
| 303 |
+
]
|
| 304 |
+
for entity in entities
|
| 305 |
+
]
|
| 306 |
+
|
| 307 |
+
def get_clinical_annotations(self, entities: ResultSet, text: str) -> list:
|
| 308 |
+
"""Extract the offset, the text and the type of the entity.
|
| 309 |
+
|
| 310 |
Args:
|
| 311 |
entities: The entities to extract.
|
| 312 |
text: The text of the document.
|
|
|
|
| 318 |
int(entity.get("begin")),
|
| 319 |
int(entity.get("end")),
|
| 320 |
text[int(entity.get("begin")) : int(entity.get("end"))],
|
| 321 |
+
entity.get("entityID"),
|
| 322 |
]
|
| 323 |
for entity in entities
|
| 324 |
]
|
|
|
|
| 343 |
soup = BeautifulSoup(soup_file, "xml")
|
| 344 |
text = soup.find("cas:Sofa").get("sofaString")
|
| 345 |
yield {
|
| 346 |
+
"CLINENTITY": self.get_clinical_annotations(
|
| 347 |
soup.find_all("custom:CLINENTITY"), text
|
| 348 |
),
|
| 349 |
"EVENT": self.get_annotations(soup.find_all("custom:EVENT"), text),
|
|
|
|
| 385 |
[token[0] - sentence[0], token[1] - sentence[0]] for token in filtered_tokens
|
| 386 |
]
|
| 387 |
clinical_labels = ["O"] * len(filtered_tokens)
|
| 388 |
+
clinical_cuid = ["CUI_LESS"] * len(filtered_tokens)
|
| 389 |
temporal_information_labels = ["O"] * len(filtered_tokens)
|
| 390 |
for entity_type in [
|
| 391 |
"CLINENTITY",
|
|
|
|
| 410 |
clinical_labels[idx_token] = f"B-{entity_type}"
|
| 411 |
else:
|
| 412 |
clinical_labels[idx_token] = f"I-{entity_type}"
|
| 413 |
+
clinical_cuid[idx_token] = entities[-1]
|
| 414 |
else:
|
| 415 |
if idx_token == annotated_tokens[0]:
|
| 416 |
temporal_information_labels[idx_token] = f"B-{entity_type}"
|
|
|
|
| 420 |
"text": sentence[-1],
|
| 421 |
"tokens": list(map(lambda token: token[2], filtered_tokens)),
|
| 422 |
"clinical_entity_tags": clinical_labels,
|
| 423 |
+
"clinical_entity_cuid": clinical_cuid,
|
| 424 |
"temporal_information_tags": temporal_information_labels,
|
| 425 |
"tokens_offsets": tokens_offsets,
|
| 426 |
}
|
| 427 |
guid += 1
|
| 428 |
+
|
| 429 |
+
if __name__ == "__main__":
|
| 430 |
+
builder = E3C()
|
| 431 |
+
builder.download_and_prepare()
|