File size: 1,009 Bytes
61ad433
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
"""Gradio_NER_App.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1057X-kosrWdfvyaGGLZT1ffvKfafdapz
"""

#!pip install -q transformers

from transformers import pipeline

ner_pipeline = pipeline("ner", model="ocaklisemih/multilingual-xlm-roberta-for-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}

#!pip install -q gradio

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)