Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -137,10 +137,17 @@ 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
|
| 141 |
try:
|
| 142 |
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 143 |
-
selected_paragraph =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
return selected_paragraph
|
| 145 |
except (IndexError, ValueError):
|
| 146 |
return "Error"
|
|
@@ -440,7 +447,7 @@ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
|
|
| 440 |
gr.Markdown("### PDF 1 Analysis")
|
| 441 |
|
| 442 |
selected_paragraph_1 = gr.Textbox(label="Selected Paragraph 1 Content", lines=4)
|
| 443 |
-
paragraph_1_dropdown.select(fn=
|
| 444 |
summarize_btn1 = gr.Button("Summarize Text from PDF 1")
|
| 445 |
summary_textbox_1 = gr.Textbox(label="Summary for PDF 1", lines=2)
|
| 446 |
|
|
@@ -470,7 +477,7 @@ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
|
|
| 470 |
gr.Markdown("### PDF 2 Analysis")
|
| 471 |
|
| 472 |
selected_paragraph_2 = gr.Textbox(label="Selected Paragraph 2 Content", lines=4)
|
| 473 |
-
paragraph_2_dropdown.select(fn=
|
| 474 |
# Display selected paragraph from PDF 2
|
| 475 |
selected_paragraph_2.change(fn=show, inputs=paragraph_2_dropdown, outputs=selected_paragraph_2)
|
| 476 |
|
|
|
|
| 137 |
def get_pdf_files(folder):
|
| 138 |
return [f for f in os.listdir(folder) if f.endswith('.pdf')]
|
| 139 |
|
| 140 |
+
def show1(paragraph):
|
| 141 |
try:
|
| 142 |
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 143 |
+
selected_paragraph = stored_paragraphs_1[paragraph_index]
|
| 144 |
+
return selected_paragraph
|
| 145 |
+
except (IndexError, ValueError):
|
| 146 |
+
return "Error"
|
| 147 |
+
def show2(paragraph):
|
| 148 |
+
try:
|
| 149 |
+
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 150 |
+
selected_paragraph = stored_paragraphs_2[paragraph_index]
|
| 151 |
return selected_paragraph
|
| 152 |
except (IndexError, ValueError):
|
| 153 |
return "Error"
|
|
|
|
| 447 |
gr.Markdown("### PDF 1 Analysis")
|
| 448 |
|
| 449 |
selected_paragraph_1 = gr.Textbox(label="Selected Paragraph 1 Content", lines=4)
|
| 450 |
+
paragraph_1_dropdown.select(fn=show1, inputs = paragraph_1_dropdown, outputs=selected_paragraph_1)
|
| 451 |
summarize_btn1 = gr.Button("Summarize Text from PDF 1")
|
| 452 |
summary_textbox_1 = gr.Textbox(label="Summary for PDF 1", lines=2)
|
| 453 |
|
|
|
|
| 477 |
gr.Markdown("### PDF 2 Analysis")
|
| 478 |
|
| 479 |
selected_paragraph_2 = gr.Textbox(label="Selected Paragraph 2 Content", lines=4)
|
| 480 |
+
paragraph_2_dropdown.select(fn=show2, inputs = paragraph_2_dropdown, outputs=selected_paragraph_2)
|
| 481 |
# Display selected paragraph from PDF 2
|
| 482 |
selected_paragraph_2.change(fn=show, inputs=paragraph_2_dropdown, outputs=selected_paragraph_2)
|
| 483 |
|