Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,31 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
-
"""
|
3 |
-
Created on Thu Aug 8 15:10:36 2024
|
4 |
-
|
5 |
-
@author: Ali PAK
|
6 |
-
"""
|
7 |
-
|
8 |
-
|
9 |
-
import
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
"
|
21 |
-
"
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
gr.
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
30 |
demo.launch(share=True)
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""
|
3 |
+
Created on Thu Aug 8 15:10:36 2024
|
4 |
+
|
5 |
+
@author: Ali PAK
|
6 |
+
"""
|
7 |
+
!pip install numpy
|
8 |
+
from transformers import pipeline
|
9 |
+
import gradio as gr
|
10 |
+
import torch
|
11 |
+
|
12 |
+
|
13 |
+
ner_pipeline=pipeline("ner",model="apak/bert-base-uncased-for-ner")
|
14 |
+
|
15 |
+
def ner(text):
|
16 |
+
output=ner_pipeline(text,aggregation_strategy="simple")
|
17 |
+
return {"text":text, "entities": output}
|
18 |
+
|
19 |
+
examples=[
|
20 |
+
" My name is Jessica, I work at Google",
|
21 |
+
" Arsenal won the FA Cup.",
|
22 |
+
" Rashid played for Galatasaray Istanbul."
|
23 |
+
]
|
24 |
+
demo=gr.Interface(
|
25 |
+
ner,
|
26 |
+
gr.Textbox(placeholder="Enter sentence here..."),
|
27 |
+
gr.HighlightedText(),
|
28 |
+
examples=examples
|
29 |
+
)
|
30 |
+
|
31 |
demo.launch(share=True)
|