Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -137,8 +137,14 @@ def process_paragraph_2_sent_tone_bis(paragraph):
|
|
137 |
def get_pdf_files(folder):
|
138 |
return [f for f in os.listdir(folder) if f.endswith('.pdf')]
|
139 |
|
140 |
-
def show(
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
def get_excel_files(folder):
|
144 |
return [f for f in os.listdir(folder) if f.endswith('.xlsx')]
|
@@ -435,7 +441,7 @@ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
|
|
435 |
gr.Markdown("### PDF 1 Analysis")
|
436 |
|
437 |
selected_paragraph_1 = gr.Textbox(label="Selected Paragraph 1 Content", lines=4)
|
438 |
-
paragraph_1_dropdown.select(fn=show, inputs = paragraph_1_dropdown, outputs=selected_paragraph_1)
|
439 |
summarize_btn1 = gr.Button("Summarize Text from PDF 1")
|
440 |
summary_textbox_1 = gr.Textbox(label="Summary for PDF 1", lines=2)
|
441 |
|
@@ -465,7 +471,7 @@ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
|
|
465 |
gr.Markdown("### PDF 2 Analysis")
|
466 |
|
467 |
selected_paragraph_2 = gr.Textbox(label="Selected Paragraph 2 Content", lines=4)
|
468 |
-
paragraph_2_dropdown.select(fn=show, inputs = paragraph_2_dropdown, outputs=selected_paragraph_2)
|
469 |
# Display selected paragraph from PDF 2
|
470 |
selected_paragraph_2.change(fn=show, inputs=paragraph_2_dropdown, outputs=selected_paragraph_2)
|
471 |
|
|
|
137 |
def get_pdf_files(folder):
|
138 |
return [f for f in os.listdir(folder) if f.endswith('.pdf')]
|
139 |
|
140 |
+
def show(paragraph, stored_paragraphs):
|
141 |
+
try:
|
142 |
+
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
143 |
+
selected_paragraph = stored_paragraphs[paragraph_index]
|
144 |
+
summary = summarize_text(selected_paragraph)
|
145 |
+
return f"{selected_paragraph}"
|
146 |
+
except (IndexError, ValueError):
|
147 |
+
return "Error"
|
148 |
|
149 |
def get_excel_files(folder):
|
150 |
return [f for f in os.listdir(folder) if f.endswith('.xlsx')]
|
|
|
441 |
gr.Markdown("### PDF 1 Analysis")
|
442 |
|
443 |
selected_paragraph_1 = gr.Textbox(label="Selected Paragraph 1 Content", lines=4)
|
444 |
+
paragraph_1_dropdown.select(fn=lambda p: show(p, stored_paragraphs_1), inputs = paragraph_1_dropdown, outputs=selected_paragraph_1)
|
445 |
summarize_btn1 = gr.Button("Summarize Text from PDF 1")
|
446 |
summary_textbox_1 = gr.Textbox(label="Summary for PDF 1", lines=2)
|
447 |
|
|
|
471 |
gr.Markdown("### PDF 2 Analysis")
|
472 |
|
473 |
selected_paragraph_2 = gr.Textbox(label="Selected Paragraph 2 Content", lines=4)
|
474 |
+
paragraph_2_dropdown.select(fn=lambda p: show(p, stored_paragraphs_2), inputs = paragraph_2_dropdown, outputs=selected_paragraph_2)
|
475 |
# Display selected paragraph from PDF 2
|
476 |
selected_paragraph_2.change(fn=show, inputs=paragraph_2_dropdown, outputs=selected_paragraph_2)
|
477 |
|