File size: 786 Bytes
ef7e0b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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, 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, Ankaralı mı?'
]
demo = gr.Interface(
    ner,
    gr.Textbox(placeholder='Enter sentence here...'), # metnimizi gireceğimiz input
    gr.HighlightedText(), # varlık isimlerini renklendirmek için kullanıcaz.
    examples=examples
)
demo.launch(share=True)