Farhan1572 commited on
Commit
e4bdfb9
1 Parent(s): 80bfb1c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import spacy
2
+ import gradio as gr
3
+ from spacy import displacy
4
+ from pdfminer.high_level import extract_text
5
+
6
+ nlp = spacy.load("en_cv_info_extr")
7
+
8
+ colors = {}
9
+ for label in nlp.get_pipe('ner').labels:
10
+ colors[label] = "linear-gradient(90deg, #aa9cfc, #fc9ce7)"
11
+
12
+ options = {"ents": list(nlp.get_pipe('ner').labels), "colors": colors}
13
+
14
+ def resume_ner(file):
15
+ resume = extract_text(file.name)
16
+ doc = nlp(resume)
17
+ html = displacy.render(doc, style="ent", page=True, options=options)
18
+ html = (
19
+ "<div style='max-width:100%; max-height:500px; overflow:auto'>"
20
+ + html
21
+ + "</div>"
22
+ )
23
+ return html
24
+
25
+ demo = gr.Interface(
26
+ resume_ner,
27
+ gr.File(file_types=[".pdf"]),
28
+ ["html"],
29
+ )
30
+
31
+ demo.launch()