Keyurjotaniya007's picture
Update app.py
5135a8b verified
raw
history blame
682 Bytes
import gradio as gr
from transformers import pipeline
ner = pipeline("ner", model="Keyurjotaniya007/xlm-roberta-base-xtreme-multilingual-ner-2.0", aggregation_strategy="simple")
def extract_entities(text):
results = ner(text)
return [(ent['word'], ent['entity_group']) for ent in results]
with gr.Blocks() as demo:
gr.Markdown(instructions)
with gr.Row():
inp = gr.Textbox(label="Enter Text", placeholder="Type a sentence in any language...", lines=3)
out = gr.HighlightedText(label="Named Entities")
btn = gr.Button("Extract Entities")
btn.click(fn=extract_entities, inputs=inp, outputs=out)
if __name__ == "__main__":
demo.launch()