Cachoups commited on
Commit
6a2554d
·
verified ·
1 Parent(s): 81f4916

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -146,7 +146,7 @@ def process_and_compare(file1, sheet1, file2, sheet2):
146
  plt.savefig(file_path, format='png', bbox_inches='tight')
147
  plt.close()
148
 
149
- return file_path
150
 
151
  def find_sentences_with_keywords(text, keywords):
152
  # Split text into sentences using regular expression to match sentence-ending punctuation
@@ -194,8 +194,8 @@ def process_pdfs_and_analyze_sentiment(file1, file2, sheet):
194
  result_pdf2 = fin_ext_bis(text_pdf2)
195
 
196
  return result_pdf1, result_pdf2
197
- def change_choices(df):
198
- return gr.update(choices=df.Country.values.tolist())
199
 
200
  def generate_text(df, country, theme):
201
  # Filter the dataframe based on the country
@@ -320,7 +320,6 @@ with gr.Blocks() as demo:
320
  with gr.Column():
321
  sentiment_results_pdf1 = gr.HighlightedText(label="Sentiment Analysis - PDF 1")
322
  country_1_dropdown = gr.Dropdown(label="Select Country from Excel File 1")
323
- country_1_dropdown.change(fn =change_choices, inputs= stored_df1, outputs= country_1_dropdown)
324
  summarize_btn1_country = gr.Button("Summary for the selected country")
325
  text_result_df1 = gr.Textbox(label="Sentence for excel file 1", lines=2)
326
  summarize_btn1_country.click(fn=lambda country, theme: generate_text(stored_df1, country, theme),
@@ -330,7 +329,7 @@ with gr.Blocks() as demo:
330
  sentiment_results_pdf2 = gr.HighlightedText(label="Sentiment Analysis - PDF 2")
331
 
332
  # Button to extract text from PDFs and perform sentiment analysis
333
- b1.click(fn=process_and_compare, inputs=[file1, sheet, file2, sheet], outputs=result)
334
  b2.click(fn=process_pdfs_and_analyze_sentiment, inputs=[file1, file2, sheet], outputs=[sentiment_results_pdf1, sentiment_results_pdf2])
335
 
336
 
 
146
  plt.savefig(file_path, format='png', bbox_inches='tight')
147
  plt.close()
148
 
149
+ return file_path, stored_df1.Country.values.tolist()
150
 
151
  def find_sentences_with_keywords(text, keywords):
152
  # Split text into sentences using regular expression to match sentence-ending punctuation
 
194
  result_pdf2 = fin_ext_bis(text_pdf2)
195
 
196
  return result_pdf1, result_pdf2
197
+ #def change_choices(df):
198
+ # return gr.update(choices=df.Country.values.tolist())
199
 
200
  def generate_text(df, country, theme):
201
  # Filter the dataframe based on the country
 
320
  with gr.Column():
321
  sentiment_results_pdf1 = gr.HighlightedText(label="Sentiment Analysis - PDF 1")
322
  country_1_dropdown = gr.Dropdown(label="Select Country from Excel File 1")
 
323
  summarize_btn1_country = gr.Button("Summary for the selected country")
324
  text_result_df1 = gr.Textbox(label="Sentence for excel file 1", lines=2)
325
  summarize_btn1_country.click(fn=lambda country, theme: generate_text(stored_df1, country, theme),
 
329
  sentiment_results_pdf2 = gr.HighlightedText(label="Sentiment Analysis - PDF 2")
330
 
331
  # Button to extract text from PDFs and perform sentiment analysis
332
+ b1.click(fn=process_and_compare, inputs=[file1, sheet, file2, sheet], outputs={result,country_1_dropdown])
333
  b2.click(fn=process_pdfs_and_analyze_sentiment, inputs=[file1, file2, sheet], outputs=[sentiment_results_pdf1, sentiment_results_pdf2])
334
 
335