Weixin-Liang commited on
Commit
cc36c46
·
1 Parent(s): fbd4605

Add application file

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # REF: https://gradio.app/named_entity_recognition/
2
+ from transformers import pipeline
3
+
4
+ import gradio as gr
5
+
6
+ ner_pipeline = pipeline("ner")
7
+
8
+ examples = [
9
+ "Does Chicago have any stores and does Joe live here?",
10
+ ]
11
+
12
+ def ner(text):
13
+ output = ner_pipeline(text)
14
+ return {"text": text, "entities": output}
15
+
16
+ demo = gr.Interface(ner,
17
+ gr.Textbox(placeholder="Enter sentence here..."),
18
+ gr.HighlightedText(),
19
+ examples=examples)
20
+
21
+ demo.launch()