File size: 1,399 Bytes
3d4bfdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
tags:
  - flair
  - entity-mention-linker
---

## biosyn-sapbert-regel-bto

Biomedical Entity Mention Linking for DISEASE with MONDO Disease Ontology

- Model: [dmis-lab/biosyn-sapbert-bc5cdr-disease](https://huggingface.co/dmis-lab/biosyn-sapbert-bc5cdr-disease)
- Dictionary: [Brenda Tissue Ontology](https://mondo.monarchinitiative.org/)

### Demo: How to use in Flair

Requires:

- **[Flair](https://github.com/flairNLP/flair/)>=0.14.0** (`pip install flair` or `pip install git+https://github.com/flairNLP/flair.git`)

```python
from flair.data import Sentence
from flair.models import Classifier, EntityMentionLinker
from flair.tokenization import SciSpacyTokenizer

sentence = Sentence(
    "The mutation in the ABCD1 gene causes X-linked adrenoleukodystrophy, "
    "a neurodegenerative disease, which is exacerbated by exposure to high "
    "levels of mercury in dolphin populations.",
    use_tokenizer=SciSpacyTokenizer()
)
# load hunflair to detect the entity mentions we want to link.
tagger = Classifier.load("hunflair2")
tagger.predict(sentence)

# load the linker and dictionary
linker = EntityMentionLinker.load("regel-corpus/biosyn-sapbert-regel-mondo")
linker.predict(sentence)

# print the results for each entity mention:
for span in sentence.get_spans(tagger.label_type):
    for link in span.get_labels(linker.label_type):
      print(f"{span.text} -> {link.value}")
```