Spaces:
Running
Running
Update app.py
Browse files
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, gr.update(choices=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
|
@@ -222,6 +222,8 @@ def generate_text(df, country, theme):
|
|
222 |
Here is another table:
|
223 |
{row_str}
|
224 |
|
|
|
|
|
225 |
Summarize the adverse scenario growth for {theme} in {country} based on the data above, following a similar pattern to the example for France.
|
226 |
"""
|
227 |
|
@@ -327,9 +329,15 @@ with gr.Blocks() as demo:
|
|
327 |
outputs=text_result_df1)
|
328 |
with gr.Column():
|
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 |
|
|
|
146 |
plt.savefig(file_path, format='png', bbox_inches='tight')
|
147 |
plt.close()
|
148 |
|
149 |
+
return file_path, gr.update(choices=stored_df1.Country.values.tolist()), gr.update(choices=stored_df2.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
|
|
|
222 |
Here is another table:
|
223 |
{row_str}
|
224 |
|
225 |
+
The theme is {theme}
|
226 |
+
|
227 |
Summarize the adverse scenario growth for {theme} in {country} based on the data above, following a similar pattern to the example for France.
|
228 |
"""
|
229 |
|
|
|
329 |
outputs=text_result_df1)
|
330 |
with gr.Column():
|
331 |
sentiment_results_pdf2 = gr.HighlightedText(label="Sentiment Analysis - PDF 2")
|
332 |
+
country_2_dropdown = gr.Dropdown(label="Select Country from Excel File 2")
|
333 |
+
summarize_btn2_country = gr.Button("Summary for the selected country")
|
334 |
+
text_result_df2 = gr.Textbox(label="Sentence for excel file 2", lines=2)
|
335 |
+
summarize_btn2_country.click(fn=lambda country, theme: generate_text(stored_df2, country, theme),
|
336 |
+
inputs=[country_2_dropdown, sheet],
|
337 |
+
outputs=text_result_df2)
|
338 |
|
339 |
# Button to extract text from PDFs and perform sentiment analysis
|
340 |
+
b1.click(fn=process_and_compare, inputs=[file1, sheet, file2, sheet], outputs=[result,country_1_dropdown, country_2_dropdown])
|
341 |
b2.click(fn=process_pdfs_and_analyze_sentiment, inputs=[file1, file2, sheet], outputs=[sentiment_results_pdf1, sentiment_results_pdf2])
|
342 |
|
343 |
|