Views
No views yet
pip install flair or pip install git+https://github.com/flairNLP/flair.git)1from flair.data import Sentence
2from flair.nn import Classifier
3from flair.models import EntityMentionLinker
4
5sentence = Sentence("Behavioral abnormalities in the Fmr1 KO2 Mouse Model of Fragile X Syndrome")
6
7# load hunflair to detect the entity mentions we want to link.
8tagger = Classifier.load("hunflair")
9tagger.predict(sentence)
10
11# load the linker and dictionary
12linker = EntityMentionLinker.load("helpmefindaname/flair-eml-biobert-ncbi-disease")
13dictionary = linker.dictionary
14
15# find then candidates for the mentions
16linker.predict(sentence)
17
18# print the results for each entity mention:
19for span in sentence.get_spans(linker.entity_label_type):
20 print(f"Span: {span.text}")
21 for candidate_label in span.get_labels(linker.label_type):
22 candidate = dictionary[candidate_label.value]
23 print(f"Candidate: {candidate.concept_name}")linker = EntityMentionLinker.build("dmis-lab/biosyn-biobert-ncbi-disease", "diseases", dictionary_name_or_path="ctd-diseases", hybrid_search=False, entity_type="diseases-eml")