ychafiqui commited on
Commit
e0567b2
1 Parent(s): 9897ebf

Update app

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -1,7 +1,31 @@
 
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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:360px; 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()