MuntasirHossain commited on
Commit
6135ed9
·
1 Parent(s): a818880

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ os.system('python -m spacy download en_core_web_trf')
4
+ import spacy
5
+ from spacy import displacy
6
+
7
+ nlp = spacy.load("en_core_web_trf")
8
+
9
+ def ner(text):
10
+ doc = nlp(text)
11
+ html = displacy.render(doc, style="ent", page=True)
12
+ # html = displacy.render(doc, style="ent", page=True, manual=True, minify=True)
13
+ html = (
14
+ "<div style='max-width:100%; max-height:360px; overflow:auto'>"
15
+ + html
16
+ + "</div>"
17
+ )
18
+ return html
19
+
20
+ demo = gr.Interface(
21
+ ner,
22
+ gr.Textbox(placeholder="Enter sentence here..."),
23
+ outputs="html",
24
+ examples=["Mount Everest is Earth's highest mountain, located in the Mahalangur Himal sub-range of the Himalayas. Edmund Hillary and Tenzing Norgay were the \
25
+ first climbers confirmed to have reached the summit of Mount Everest on May 29, 1953."],
26
+ )
27
+
28
+ demo.launch()