Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""GradioIleNER.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colab.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1NfmayavArZT9V1I1LgMeAkM7QLmKAhXe
|
8 |
+
"""
|
9 |
+
|
10 |
+
# !pip install -q transformers
|
11 |
+
|
12 |
+
from transformers import pipeline
|
13 |
+
|
14 |
+
ner_pipeline = pipeline("ner", model="Tirendaz/roberta-base-NER")
|
15 |
+
|
16 |
+
text = "I am Tim and I work at Google"
|
17 |
+
|
18 |
+
ner_pipeline(text)
|
19 |
+
|
20 |
+
text_tr = "Benim adım Neşet ve Trendyol'da çalışıyorum"
|
21 |
+
|
22 |
+
ner_pipeline(text_tr)
|
23 |
+
|
24 |
+
ner_pipeline(text_tr, aggregation_strategy="simple")
|
25 |
+
|
26 |
+
def ner(text):
|
27 |
+
output = ner_pipeline(text, aggregation_strategy="simple")
|
28 |
+
return {"text": text, "entities": output}
|
29 |
+
|
30 |
+
# !pip install -q gradio
|
31 |
+
|
32 |
+
import gradio as gr
|
33 |
+
|
34 |
+
examples = ["My name is Tim and I live in California", "Ich arbeite bei Google in Berlin", "Neşet, Ankara'lı mı?"]
|
35 |
+
|
36 |
+
demo = gr.Interface(
|
37 |
+
ner,
|
38 |
+
gr.Textbox(placeholder="Enter text here..."),
|
39 |
+
gr.HighlightedText(),
|
40 |
+
examples=examples,
|
41 |
+
)
|
42 |
+
|
43 |
+
demo.launch(share= True)
|
44 |
+
|