-
Notifications
You must be signed in to change notification settings - Fork 1
/
label_names.py
34 lines (27 loc) · 893 Bytes
/
label_names.py
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
from typing import Dict
"""
You can update this dictionary to add more label verbalizations.
If we find a label that is not in this dictionary, we will use the label as it is.
If we find a label that is in this dictionary, we will replace it with the corresponding verbalization.
Verbalization can help the model to understand the label better.
"""
_label2name: Dict[str, str] = {
"LOC": "Location",
"PER": "Person",
"ORG": "Organization",
"MISC": "Miscellaneous",
"TARGET": "Target",
"ety": "ClinicalEntity",
"dis": "Disability",
}
_name2label: Dict[str, str] = {v: k for k, v in _label2name.items()}
def label2name(label: str) -> str:
if label in _label2name:
return _label2name[label]
else:
return label
def name2label(name: str) -> str:
if name in _name2label:
return _name2label[name]
else:
return name