Cachoups commited on
Commit
137833b
·
verified ·
1 Parent(s): 4810f30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -61
app.py CHANGED
@@ -301,7 +301,25 @@ stored_paragraphs_2 = []
301
  stored_df1 = []
302
  stored_df2 = []
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  with gr.Blocks() as demo:
 
 
305
  with gr.Tab("Methodology"):
306
  gr.Markdown("""
307
  ## Macro-economy Adverse Scenario Comparison from EBA Reports
@@ -349,70 +367,70 @@ with gr.Blocks() as demo:
349
  return gr.update(choices=updated_dropdown_1), gr.update(choices=updated_dropdown_2)
350
 
351
  b1.click(fn=update_paragraphs, inputs=[pdf1, pdf2], outputs=[paragraph_1_dropdown, paragraph_2_dropdown])
352
-
353
  with gr.Row():
354
- # Process the selected paragraph from PDF 1
355
  with gr.Column():
356
- gr.Markdown("### PDF 1 Analysis")
357
-
358
- selected_paragraph_1 = gr.Textbox(label="Selected Paragraph 1 Content", lines=4)
359
-
360
- summarize_btn1 = gr.Button("Summarize Text from PDF 1")
361
- summary_textbox_1 = gr.Textbox(label="Summary for PDF 1", lines=2)
362
-
363
- # Summarize the selected paragraph from PDF 1
364
- summarize_btn1.click(fn=lambda p: process_paragraph_1_sum(p), inputs=paragraph_1_dropdown, outputs=summary_textbox_1)
365
-
366
- sentiment_btn1 = gr.Button("Classify Financial Tone from PDF 1")
367
- sentiment_textbox_1 = gr.Textbox(label="Classification for PDF 1", lines=1)
368
-
369
- # Classify the financial tone of the selected paragraph from PDF 1
370
- sentiment_btn1.click(fn=lambda p: process_paragraph_1_sent(p), inputs=paragraph_1_dropdown, outputs=sentiment_textbox_1)
371
-
372
- analyze_btn1 = gr.Button("Analyze Financial Tone on each sentence with FinBERT-tone")
373
- fin_spans_1 = gr.HighlightedText(label="Financial Tone Analysis for PDF 1")
374
-
375
- # Analyze financial tone on each sentence using FinBERT-tone
376
- analyze_btn1.click(fn=lambda p: process_paragraph_1_sent_tone(p), inputs=paragraph_1_dropdown, outputs=fin_spans_1)
377
-
378
- analyze_btn1_ = gr.Button("Analyze Financial Tone on each sentence with ProsusAI/finbert")
379
- fin_spans_1_ = gr.HighlightedText(label="Financial Tone Analysis for PDF 1 (Bis)")
380
-
381
- # Analyze financial tone using ProsusAI/finbert
382
- analyze_btn1_.click(fn=lambda p: process_paragraph_1_sent_tone_bis(p), inputs=paragraph_1_dropdown, outputs=fin_spans_1_)
383
-
384
- # Process the selected paragraph from PDF 2
385
  with gr.Column():
386
- gr.Markdown("### PDF 2 Analysis")
387
-
388
- selected_paragraph_2 = gr.Textbox(label="Selected Paragraph 2 Content", lines=4)
389
-
390
- # Display selected paragraph from PDF 2
391
- selected_paragraph_2.change(fn=show, inputs=paragraph_2_dropdown, outputs=selected_paragraph_2)
392
-
393
- summarize_btn2 = gr.Button("Summarize Text from PDF 2")
394
- summary_textbox_2 = gr.Textbox(label="Summary for PDF 2", lines=2)
395
-
396
- # Summarize the selected paragraph from PDF 2
397
- summarize_btn2.click(fn=lambda p: process_paragraph_2_sum(p), inputs=paragraph_2_dropdown, outputs=summary_textbox_2)
398
-
399
- sentiment_btn2 = gr.Button("Classify Financial Tone from PDF 2")
400
- sentiment_textbox_2 = gr.Textbox(label="Classification for PDF 2", lines=1)
401
-
402
- # Classify the financial tone of the selected paragraph from PDF 2
403
- sentiment_btn2.click(fn=lambda p: process_paragraph_2_sent(p), inputs=paragraph_2_dropdown, outputs=sentiment_textbox_2)
404
-
405
- analyze_btn2 = gr.Button("Analyze Financial Tone on each sentence with FinBERT-tone")
406
- fin_spans_2 = gr.HighlightedText(label="Financial Tone Analysis for PDF 2")
407
-
408
- # Analyze financial tone on each sentence using FinBERT-tone for PDF 2
409
- analyze_btn2.click(fn=lambda p: process_paragraph_2_sent_tone(p), inputs=paragraph_2_dropdown, outputs=fin_spans_2)
410
-
411
- analyze_btn2_ = gr.Button("Analyze Financial Tone on each sentence with ProsusAI/finbert")
412
- fin_spans_2_ = gr.HighlightedText(label="Financial Tone Analysis for PDF 2 (Bis)")
413
-
414
- # Analyze financial tone using ProsusAI/finbert for PDF 2
415
- analyze_btn2_.click(fn=lambda p: process_paragraph_2_sent_tone_bis(p), inputs=paragraph_2_dropdown, outputs=fin_spans_2_)
 
416
 
417
  with gr.Tab("Financial Report Table Analysis"):
418
  # New tab content goes here
 
301
  stored_df1 = []
302
  stored_df2 = []
303
 
304
+ # CSS for custom background colors
305
+ custom_css = """
306
+ <style>
307
+ .pdf1-analysis {
308
+ background-color: #f0f8ff; /* Light blue background for PDF1 */
309
+ padding: 20px;
310
+ border-radius: 10px;
311
+ }
312
+
313
+ .pdf2-analysis {
314
+ background-color: #ffe4e1; /* Light pink background for PDF2 */
315
+ padding: 20px;
316
+ border-radius: 10px;
317
+ }
318
+ </style>"""
319
+
320
  with gr.Blocks() as demo:
321
+ gr.HTML(custom_css)
322
+
323
  with gr.Tab("Methodology"):
324
  gr.Markdown("""
325
  ## Macro-economy Adverse Scenario Comparison from EBA Reports
 
367
  return gr.update(choices=updated_dropdown_1), gr.update(choices=updated_dropdown_2)
368
 
369
  b1.click(fn=update_paragraphs, inputs=[pdf1, pdf2], outputs=[paragraph_1_dropdown, paragraph_2_dropdown])
370
+ gr.Markdown("---")
371
  with gr.Row():
372
+ # PDF 1 Analysis section with custom background
373
  with gr.Column():
374
+ with gr.Box():
375
+ gr.Markdown("<div class='pdf1-analysis'><h3>PDF 1 Analysis</h3></div>")
376
+ selected_paragraph_1 = gr.Textbox(label="Selected Paragraph 1 Content", lines=4)
377
+ summarize_btn1 = gr.Button("Summarize Text from PDF 1")
378
+ summary_textbox_1 = gr.Textbox(label="Summary for PDF 1", lines=2)
379
+
380
+ # Summarize the selected paragraph from PDF 1
381
+ summarize_btn1.click(fn=lambda p: process_paragraph_1_sum(p), inputs=paragraph_1_dropdown, outputs=summary_textbox_1)
382
+
383
+ sentiment_btn1 = gr.Button("Classify Financial Tone from PDF 1")
384
+ sentiment_textbox_1 = gr.Textbox(label="Classification for PDF 1", lines=1)
385
+
386
+ # Classify the financial tone of the selected paragraph from PDF 1
387
+ sentiment_btn1.click(fn=lambda p: process_paragraph_1_sent(p), inputs=paragraph_1_dropdown, outputs=sentiment_textbox_1)
388
+
389
+ analyze_btn1 = gr.Button("Analyze Financial Tone on each sentence with FinBERT-tone")
390
+ fin_spans_1 = gr.HighlightedText(label="Financial Tone Analysis for PDF 1")
391
+
392
+ # Analyze financial tone on each sentence using FinBERT-tone
393
+ analyze_btn1.click(fn=lambda p: process_paragraph_1_sent_tone(p), inputs=paragraph_1_dropdown, outputs=fin_spans_1)
394
+
395
+ analyze_btn1_ = gr.Button("Analyze Financial Tone on each sentence with ProsusAI/finbert")
396
+ fin_spans_1_ = gr.HighlightedText(label="Financial Tone Analysis for PDF 1 (Bis)")
397
+
398
+ # Analyze financial tone using ProsusAI/finbert
399
+ analyze_btn1_.click(fn=lambda p: process_paragraph_1_sent_tone_bis(p), inputs=paragraph_1_dropdown, outputs=fin_spans_1_)
400
+
401
+ # PDF 2 Analysis section with custom background
 
402
  with gr.Column():
403
+ with gr.Box():
404
+ gr.Markdown("<div class='pdf2-analysis'><h3>PDF 2 Analysis</h3></div>")
405
+ selected_paragraph_2 = gr.Textbox(label="Selected Paragraph 2 Content", lines=4)
406
+
407
+ # Display selected paragraph from PDF 2
408
+ selected_paragraph_2.change(fn=show, inputs=paragraph_2_dropdown, outputs=selected_paragraph_2)
409
+
410
+ summarize_btn2 = gr.Button("Summarize Text from PDF 2")
411
+ summary_textbox_2 = gr.Textbox(label="Summary for PDF 2", lines=2)
412
+
413
+ # Summarize the selected paragraph from PDF 2
414
+ summarize_btn2.click(fn=lambda p: process_paragraph_2_sum(p), inputs=paragraph_2_dropdown, outputs=summary_textbox_2)
415
+
416
+ sentiment_btn2 = gr.Button("Classify Financial Tone from PDF 2")
417
+ sentiment_textbox_2 = gr.Textbox(label="Classification for PDF 2", lines=1)
418
+
419
+ # Classify the financial tone of the selected paragraph from PDF 2
420
+ sentiment_btn2.click(fn=lambda p: process_paragraph_2_sent(p), inputs=paragraph_2_dropdown, outputs=sentiment_textbox_2)
421
+
422
+ analyze_btn2 = gr.Button("Analyze Financial Tone on each sentence with FinBERT-tone")
423
+ fin_spans_2 = gr.HighlightedText(label="Financial Tone Analysis for PDF 2")
424
+
425
+ # Analyze financial tone on each sentence using FinBERT-tone for PDF 2
426
+ analyze_btn2.click(fn=lambda p: process_paragraph_2_sent_tone(p), inputs=paragraph_2_dropdown, outputs=fin_spans_2)
427
+
428
+ analyze_btn2_ = gr.Button("Analyze Financial Tone on each sentence with ProsusAI/finbert")
429
+ fin_spans_2_ = gr.HighlightedText(label="Financial Tone Analysis for PDF 2 (Bis)")
430
+
431
+ # Analyze financial tone using ProsusAI/finbert for PDF 2
432
+ analyze_btn2_.click(fn=lambda p: process_paragraph_2_sent_tone_bis(p), inputs=paragraph_2_dropdown, outputs=fin_spans_2_)
433
+
434
 
435
  with gr.Tab("Financial Report Table Analysis"):
436
  # New tab content goes here