Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -349,7 +349,7 @@ def generate_text(df, country, theme):
|
|
349 |
{row_str}
|
350 |
Topic: {theme}
|
351 |
|
352 |
-
Describe the adverse growth in the provided data year by year
|
353 |
"""
|
354 |
prompt1 = f"""
|
355 |
Here is an example of how to describe adverse growth data for a given country:
|
@@ -536,26 +536,31 @@ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
|
|
536 |
|
537 |
|
538 |
b1 = gr.Button("Compare Data")
|
539 |
-
b2 = gr.Button("Extract text information")
|
540 |
|
541 |
with gr.Row():
|
542 |
with gr.Column():
|
543 |
sentiment_results_pdf1 = gr.HighlightedText(label="Sentiment Analysis - PDF 1")
|
544 |
-
|
545 |
-
summarize_btn1_country = gr.Button("Summary for the selected country")
|
546 |
-
text_result_df1 = gr.Textbox(label="Sentence for excel file 1", lines=2)
|
547 |
-
summarize_btn1_country.click(fn=lambda country, theme: generate_text(stored_df1, country, theme),
|
548 |
-
inputs=[country_1_dropdown, sheet],
|
549 |
-
outputs=text_result_df1)
|
550 |
with gr.Column():
|
551 |
sentiment_results_pdf2 = gr.HighlightedText(label="Sentiment Analysis - PDF 2")
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
# Button to extract text from PDFs and perform sentiment analysis
|
560 |
b1.click(fn=process_and_compare, inputs=[file1, sheet, file2, sheet], outputs=[result,country_1_dropdown, country_2_dropdown])
|
561 |
b2.click(fn=process_pdfs_and_analyze_sentiment, inputs=[file1, file2, sheet], outputs=[sentiment_results_pdf1, sentiment_results_pdf2])
|
|
|
349 |
{row_str}
|
350 |
Topic: {theme}
|
351 |
|
352 |
+
Describe the adverse growth in the provided data year by year following the pattern in the example, highlighting whether the values increased or decreased each year.
|
353 |
"""
|
354 |
prompt1 = f"""
|
355 |
Here is an example of how to describe adverse growth data for a given country:
|
|
|
536 |
|
537 |
|
538 |
b1 = gr.Button("Compare Data")
|
539 |
+
b2 = gr.Button("Extract text information from PDFs")
|
540 |
|
541 |
with gr.Row():
|
542 |
with gr.Column():
|
543 |
sentiment_results_pdf1 = gr.HighlightedText(label="Sentiment Analysis - PDF 1")
|
544 |
+
|
|
|
|
|
|
|
|
|
|
|
545 |
with gr.Column():
|
546 |
sentiment_results_pdf2 = gr.HighlightedText(label="Sentiment Analysis - PDF 2")
|
547 |
+
|
548 |
+
with gr.Row():
|
549 |
+
with gr.Group("Adverse growth trends"):
|
550 |
+
with gr.Column():
|
551 |
+
country_1_dropdown = gr.Dropdown(label="Select Country from Excel File 1")
|
552 |
+
summarize_btn1_country = gr.Button("Summary for the selected country")
|
553 |
+
text_result_df1 = gr.Textbox(label="Sentence for excel file 1", lines=2)
|
554 |
+
summarize_btn1_country.click(fn=lambda country, theme: generate_text(stored_df1, country, theme),
|
555 |
+
inputs=[country_1_dropdown, sheet],
|
556 |
+
outputs=text_result_df1)
|
557 |
+
with gr.Column():
|
558 |
+
country_2_dropdown = gr.Dropdown(label="Select Country from Excel File 2")
|
559 |
+
summarize_btn2_country = gr.Button("Summary for the selected country")
|
560 |
+
text_result_df2 = gr.Textbox(label="Sentence for excel file 2", lines=2)
|
561 |
+
summarize_btn2_country.click(fn=lambda country, theme: generate_text(stored_df2, country, theme),
|
562 |
+
inputs=[country_2_dropdown, sheet],
|
563 |
+
outputs=text_result_df2)
|
564 |
# Button to extract text from PDFs and perform sentiment analysis
|
565 |
b1.click(fn=process_and_compare, inputs=[file1, sheet, file2, sheet], outputs=[result,country_1_dropdown, country_2_dropdown])
|
566 |
b2.click(fn=process_pdfs_and_analyze_sentiment, inputs=[file1, file2, sheet], outputs=[sentiment_results_pdf1, sentiment_results_pdf2])
|