ertyazilim commited on
Commit
8adf150
1 Parent(s): b2ec71a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Gradio_NER_App.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1jJt0EzAjNDS_YlBT_ZNjBx562ezPBpX-
8
+ """
9
+
10
+ # !pip install -q transformers
11
+
12
+ from transformers import pipeline
13
+
14
+ ner_pipeline = pipeline("ner", model="ertyazilim/multilingual-xlm-roberta-for-ner")
15
+
16
+ text = "I am Tim and I work at Google"
17
+
18
+ ner_pipeline(text)
19
+
20
+ text_tr = "Benim adım Ali 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 = [
35
+ "My name is Tim and I live in California",
36
+ "Ich arbeite bei Google in Berlin",
37
+ "Ali, Ankaralı mı?"
38
+ ]
39
+
40
+ demo = gr.Interface(
41
+ ner,
42
+ gr.Textbox(placeholder = "Enter sentence here..."),
43
+ gr.HighlightedText(),
44
+ examples = examples
45
+ )
46
+
47
+ demo.launch(share=True)
48
+