Spaces:
Runtime error
Runtime error
samarthagarwal23
commited on
Commit
•
c010f14
1
Parent(s):
8af8a15
Update app.py
Browse files
app.py
CHANGED
@@ -70,8 +70,10 @@ def cstr_break(s, color='black'):
|
|
70 |
|
71 |
def print_colored(text, start_idx, end_idx, confidence):
|
72 |
conf_str = 'Confidence: ' + confidence
|
73 |
-
a =
|
74 |
-
|
|
|
|
|
75 |
return a
|
76 |
|
77 |
def final_qa_pipeline(file, query):
|
@@ -95,7 +97,7 @@ def final_qa_pipeline(file, query):
|
|
95 |
# print_colored(fnl_['doc'], fnl_['start'], fnl_['end'])
|
96 |
# print(colored("Confidence score of ") + colored(str(fnl_['score'])[:4], attrs=['bold']))
|
97 |
else:
|
98 |
-
return ("No match"
|
99 |
|
100 |
examples = [
|
101 |
[os.path.abspath("dbs-annual-report-2020.pdf"), "how much dividend was paid to shareholders ?"],
|
@@ -109,7 +111,7 @@ examples = [
|
|
109 |
iface = gr.Interface(
|
110 |
fn = final_qa_pipeline,
|
111 |
inputs = [gr.inputs.File(label="input pdf file"), gr.inputs.Textbox(label="Question:")],
|
112 |
-
outputs = [gr.outputs.HTML(label="Predicted answer")
|
113 |
examples=examples,
|
114 |
title = "Question Answering on company annual reports",
|
115 |
description = "Navigate long annual reports by using Machine learning to answer your questions. \nSimply upload any annual report pdf you are interested in and ask model a question OR load an example from below."
|
|
|
70 |
|
71 |
def print_colored(text, start_idx, end_idx, confidence):
|
72 |
conf_str = 'Confidence: ' + confidence
|
73 |
+
a = cstr(' '.join([text[:start_idx], \
|
74 |
+
cstr_bold(text[start_idx:end_idx], color='red'), \
|
75 |
+
text[end_idx:], \
|
76 |
+
cstr_break(conf_str, color='yellow')]), color='black')
|
77 |
return a
|
78 |
|
79 |
def final_qa_pipeline(file, query):
|
|
|
97 |
# print_colored(fnl_['doc'], fnl_['start'], fnl_['end'])
|
98 |
# print(colored("Confidence score of ") + colored(str(fnl_['score'])[:4], attrs=['bold']))
|
99 |
else:
|
100 |
+
return ("No match")
|
101 |
|
102 |
examples = [
|
103 |
[os.path.abspath("dbs-annual-report-2020.pdf"), "how much dividend was paid to shareholders ?"],
|
|
|
111 |
iface = gr.Interface(
|
112 |
fn = final_qa_pipeline,
|
113 |
inputs = [gr.inputs.File(label="input pdf file"), gr.inputs.Textbox(label="Question:")],
|
114 |
+
outputs = [gr.outputs.HTML(label="Predicted answer")],
|
115 |
examples=examples,
|
116 |
title = "Question Answering on company annual reports",
|
117 |
description = "Navigate long annual reports by using Machine learning to answer your questions. \nSimply upload any annual report pdf you are interested in and ask model a question OR load an example from below."
|