Cachoups commited on
Commit
87bb9b5
·
verified ·
1 Parent(s): 6d11648

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -646,6 +646,28 @@ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
646
  # Button to extract text from PDFs and perform sentiment analysis
647
  b1.click(fn=process_and_compare, inputs=[file1, sheet, file2, sheet], outputs=[result ,country_1_dropdown, country_2_dropdown])
648
  b2.click(fn=process_pdfs_and_analyze_sentiment, inputs=[file1, file2, sheet], outputs=[sentiment_results_pdf1, sentiment_results_pdf2])
649
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
650
 
651
  demo.launch()
 
646
  # Button to extract text from PDFs and perform sentiment analysis
647
  b1.click(fn=process_and_compare, inputs=[file1, sheet, file2, sheet], outputs=[result ,country_1_dropdown, country_2_dropdown])
648
  b2.click(fn=process_pdfs_and_analyze_sentiment, inputs=[file1, file2, sheet], outputs=[sentiment_results_pdf1, sentiment_results_pdf2])
649
+ with gr.Tab("Fed data analysis"):
650
+ gr.Markdown("## Sentiment Analysis Overview")
651
+ # Display DataFrame
652
+ df = pd.read("/data/2019_2024_minutes.csv")
653
+ df['Positive_ratio'] = df['Positive'] / df['Total_paragraphs']
654
+ df['Negative_ratio'] = df['Negative'] / df['Total_paragraphs']
655
+ df['Neutral_ratio'] = df['Neutral'] / df['Total_paragraphs']
656
+ data_table = gr.DataFrame(value=df, label="Sentiment Data")
657
+ def display_data_and_plot():
658
+ return df, df[['Date', 'Positive_ratio', 'Negative_ratio', 'Neutral_ratio']]
659
+ # Line plot for the ratios
660
+ line_plot = gr.LinePlot(
661
+ value=df[['Date', 'Positive_ratio', 'Negative_ratio', 'Neutral_ratio']],
662
+ x='Date',
663
+ y=['Positive_ratio', 'Negative_ratio', 'Neutral_ratio'],
664
+ title="Sentiment Ratios Over Time",
665
+ y_lim=[0, 1], # Limit y-axis to 0-1 since it's a ratio
666
+ legend=["Positive Ratio", "Negative Ratio", "Neutral Ratio"]
667
+ )
668
+
669
+ # Show table and plot
670
+ display_data_and_plot_btn = gr.Button("Display Data and Plot")
671
+ display_data_and_plot_btn.click(fn=display_data_and_plot, outputs=[data_table, line_plot])
672
 
673
  demo.launch()