Spaces:
Runtime error
Runtime error
denizzunluu
commited on
Commit
•
1647e37
1
Parent(s):
c3bbf8f
Upload app.py.py
Browse files
app.py.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""Building-A-NER-App
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1bYdWk-RnDhGzdEClGI-n6X8W4P2Nnh6H
|
8 |
+
"""
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
#!pip install -U tensorflow-probability
|
13 |
+
|
14 |
+
from transformers import pipeline
|
15 |
+
|
16 |
+
ner_pipeline = pipeline("ner", model="Tirendaz/roberta-base-NER")
|
17 |
+
|
18 |
+
text = "I am Tim and I work at FaceBook."
|
19 |
+
|
20 |
+
ner_pipeline(text)
|
21 |
+
|
22 |
+
ner_pipeline(text, aggregation_strategy="simple")
|
23 |
+
|
24 |
+
def ner(text):
|
25 |
+
output = ner_pipeline(text, aggregation_strategy="simple")
|
26 |
+
return {"text": text, "entities": output}
|
27 |
+
|
28 |
+
ner(text)
|
29 |
+
|
30 |
+
import gradio as gr
|
31 |
+
|
32 |
+
examples = [
|
33 |
+
"My name is Tim and I live in California",
|
34 |
+
"Ich arbeite bei Google in Berlin",
|
35 |
+
"Ali, Ankara'lı mı?"
|
36 |
+
]
|
37 |
+
|
38 |
+
demo = gr.Interface(
|
39 |
+
ner,
|
40 |
+
gr.Textbox(placeholder="Enter a sentence here..."),
|
41 |
+
gr.HighlightedText(),
|
42 |
+
examples = examples
|
43 |
+
)
|
44 |
+
|
45 |
+
demo.launch(share = True)
|