medicalner / app.py
Wilame Lima
removeplaceholder
d80f301
from functions import *
# set the title
st.sidebar.title(DASHBOARD_TITLE)
# add an explanation of what is NER and why it is important for medical tasks
st.sidebar.markdown(
f"""
Named Entity Recognition (NER) is a subtask of information extraction that locates and classifies named entities mentioned in unstructured text into pre-defined categories such as the names of persons, organizations, locations, expressions of times, quantities, monetary values, percentages, etc.
In the medical domain, NER can be used to extract entities such as symptoms, diseases, treatments, and more. This can be useful for various tasks such as clinical decision support, medical coding, and more.
Model used: [{MODEL_PATH}]({MODEL_LINK})
"""
)
# load the model
with st.spinner("Loading the model..."):
model = load_pipeline()
# input
st.info("Enter the text in the text area below and click on submit to extract the entities")
text = st.text_area(label="Enter the text you want to get the entities here", placeholder="Enter the text here")
submit = st.button("Submit")
if text and submit:
# get the entities
entities = model(text)
if len(entities) == 0:
st.error("No entities found")
# annotate the entities
annotated_entities = [annotate(entity) for entity in entities]
# display the entities
st.header("Found Entities")
for an_entity in annotated_entities:
annotated_text(an_entity)