How to visualize Stanford Stanza NER results with BRAT
Question:
I am using Stanza Biomedical i2b2 processor to identify PROBLEM, TREATMENT and TEST entities in drugs data.
Python code is as follows:
import stanza
stanza.download(
"en",
package="mimc",
processors={"ner": ["i2b2"]},
verbose=False,
)
nlp = stanza.Pipeline(
"en",
package="mimc",
processors={"ner": ["i2b2"]},
verbose=False,
)
parsed_row = nlp("Prevention of phototoxicity in adult patients with erythropoietic protoporphyria (EPP).")
for ent in parsed_row.entities:
print(f"{ent.text}t{ent.type}")
NER output
phototoxicity PROBLEM
erythropoietic protoporphyria PROBLEM
I am reading the page about using brat to visualize Stanza NER annotations here https://brat.nlplab.org/embed.html
but I’ totally lost. Can anyone please help me fill the dots ? Thanks
Answers:
After a LOT of experimenting I did find a way and it works well, although the following code is not robust at all, just a proof of concept:
I am using Stanza Biomedical i2b2 processor to identify PROBLEM, TREATMENT and TEST entities in drugs data.
Python code is as follows:
import stanza
stanza.download(
"en",
package="mimc",
processors={"ner": ["i2b2"]},
verbose=False,
)
nlp = stanza.Pipeline(
"en",
package="mimc",
processors={"ner": ["i2b2"]},
verbose=False,
)
parsed_row = nlp("Prevention of phototoxicity in adult patients with erythropoietic protoporphyria (EPP).")
for ent in parsed_row.entities:
print(f"{ent.text}t{ent.type}")
NER output
phototoxicity PROBLEM
erythropoietic protoporphyria PROBLEM
I am reading the page about using brat to visualize Stanza NER annotations here https://brat.nlplab.org/embed.html
but I’ totally lost. Can anyone please help me fill the dots ? Thanks
After a LOT of experimenting I did find a way and it works well, although the following code is not robust at all, just a proof of concept: