NER-Demo / app.py
denizzunluu's picture
Rename app.py.py to app.py
6df170d
raw
history blame
906 Bytes
# -*- coding: utf-8 -*-
"""Building-A-NER-App
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1bYdWk-RnDhGzdEClGI-n6X8W4P2Nnh6H
"""
#!pip install -U tensorflow-probability
from transformers import pipeline
ner_pipeline = pipeline("ner", model="Tirendaz/roberta-base-NER")
text = "I am Tim and I work at FaceBook."
ner_pipeline(text)
ner_pipeline(text, aggregation_strategy="simple")
def ner(text):
output = ner_pipeline(text, aggregation_strategy="simple")
return {"text": text, "entities": output}
ner(text)
import gradio as gr
examples = [
"My name is Tim and I live in California",
"Ich arbeite bei Google in Berlin",
"Ali, Ankara'lı mı?"
]
demo = gr.Interface(
ner,
gr.Textbox(placeholder="Enter a sentence here..."),
gr.HighlightedText(),
examples = examples
)
demo.launch(share = True)