Spaces:
Sleeping
Sleeping
alperaktasm
commited on
Commit
·
ef7e0b0
1
Parent(s):
9fa83af
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
ner_pipeline = pipeline('ner', model='Tirendaz/roberta-base-NER')
|
3 |
+
|
4 |
+
text = 'I am Tim and I work at Google.'
|
5 |
+
ner_pipeline(text)
|
6 |
+
|
7 |
+
text_tr = "Benim adım Ali ve Trendyol'da çalışıyorum"
|
8 |
+
ner_pipeline(text_tr, aggregation_strategy='simple')
|
9 |
+
|
10 |
+
def ner(text):
|
11 |
+
output = ner_pipeline(text, aggregation_strategy='simple')
|
12 |
+
return {'text': text, 'entities': output}
|
13 |
+
|
14 |
+
import gradio as gr
|
15 |
+
|
16 |
+
examples = [
|
17 |
+
'My name is Tim and I live in California',
|
18 |
+
'Ich arbeite bei Google in Berlin',
|
19 |
+
'Ali, Ankaralı mı?'
|
20 |
+
]
|
21 |
+
demo = gr.Interface(
|
22 |
+
ner,
|
23 |
+
gr.Textbox(placeholder='Enter sentence here...'), # metnimizi gireceğimiz input
|
24 |
+
gr.HighlightedText(), # varlık isimlerini renklendirmek için kullanıcaz.
|
25 |
+
examples=examples
|
26 |
+
)
|
27 |
+
demo.launch(share=True)
|