import gradio as gr

from ner import NER

examples = [
    [
        'scientist, university, city', 
        ('Dr. Paul Hammond, a renowned neurologist at'
        ' Johns Hopkins University, has recently published'
        ' a paper in the prestigious journal "Nature Neuroscience".' 
        ' His research focuses on a rare genetic mutation, found'
        ' in less than 0.01% of the population, that appears to'
        ' prevent the development of Alzheimer\'s disease.'
        ' Collaborating with researchers at the University'
        ' of California, San Francisco, the team is now working'
        ' to understand the mechanism by which this mutation'
        ' confers its protective effect.\n'
        'Funded by the National Institutes of Health, their'
        ' research could potentially open new avenues for'
        ' Alzheimer\'s treatment.')
    ],
]

ner = NER('knowledgator/UTC-DeBERTa-base-v2')

gradio_app = gr.Interface(
    ner.process,
    inputs = [
        'text', 
        gr.Textbox(placeholder="Enter sentence here..."), 
        gr.Number(value=0.0, label="threshold")
    ], 
    outputs = [gr.HighlightedText()],
    examples=examples,
    theme="huggingface",
)

if __name__ == "__main__":
    gradio_app.launch()