carblacac commited on
Commit
d7c8091
1 Parent(s): 26ac453

firs version highlight function

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -1,7 +1,19 @@
 
 
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
+ from io import StringIO, BytesIO
2
+
3
  import gradio as gr
4
+ from pdf_miner.high_level import extract_text
5
+ from transformers import pipeline
6
+
7
+ nlp = pipeline("ner", model="carblacac/ner-investing", tokenizer="carblacac/ner-investing")
8
+
9
 
10
+ def highlight_text(fileObj):
11
+ path = BytesIO(fileObj)
12
+ text = extract_text(path)
13
+ entities = nlp(text)
14
+ return {"text": text, "entities": entities}
15
 
16
+ iface = gr.Interface(fn=highlight_text,
17
+ gr.inputs.File(file_count="single", type="bytes"),
18
+ gr.HighlightedText())
19
  iface.launch()