|
|
|
"""Gradio NER App.ipynb |
|
|
|
Automatically generated by Colaboratory. |
|
|
|
Original file is located at |
|
https://colab.research.google.com/drive/1Xn7aDd9y80LflV7p-QKFbn4DAOjD1U9M |
|
""" |
|
|
|
|
|
|
|
from transformers import pipeline |
|
|
|
ner_pipeline = pipeline("ner", model="Tirendaz/roberta-base-NER") |
|
|
|
text = "I am Tim and I work at Google" |
|
|
|
ner_pipeline(text) |
|
|
|
text_tr = "Benim adım Ali ve Trendyol'da çalışıyorum" |
|
ner_pipeline(text_tr) |
|
|
|
ner_pipeline(text_tr, aggregation_strategy = "simple") |
|
|
|
def ner(text): |
|
output = ner_pipeline(text, aggregation_strategy="simple") |
|
return {"text": text, "entities": output} |
|
|
|
|
|
|
|
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 sentence here..."), |
|
gr.HighlightedText(), |
|
examples=examples |
|
) |
|
|
|
demo.launch(share=True) |
|
|
|
|