Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -182,6 +182,7 @@ def process_and_compare(file1, sheet1, file2, sheet2):
|
|
182 |
historical_col = f'Historical {year - 1}'
|
183 |
baseline_cols = [f'Baseline {year}', f'Baseline {year + 1}', f'Baseline {year + 2}']
|
184 |
adverse_cols = [f'Adverse {year}', f'Adverse {year + 1}', f'Adverse {year + 2}']
|
|
|
185 |
level_deviation_col = f'Level Deviation {year + 2}'
|
186 |
|
187 |
# Drop rows and reset index
|
@@ -196,6 +197,7 @@ def process_and_compare(file1, sheet1, file2, sheet2):
|
|
196 |
else:
|
197 |
raise ValueError(f"Expected {len(new_columns)} columns, but found {len(df.columns)} columns in the data.")
|
198 |
columns = ['Country', f'Adverse {year}', f'Adverse {year+1}', f'Adverse {year+2}', 'Adverse Cumulative']
|
|
|
199 |
return df, df[columns]
|
200 |
|
201 |
# Process both files
|
@@ -352,6 +354,7 @@ def generate_text(df, country, theme):
|
|
352 |
Given the following adverse growth data for {theme} in {country}:
|
353 |
|
354 |
{row_str}
|
|
|
355 |
|
356 |
Describe the yearly changes in adverse growth, highlighting whether the values increased or decreased, and provide the cumulative growth. Follow this example:
|
357 |
|
@@ -370,7 +373,7 @@ def generate_text(df, country, theme):
|
|
370 |
"""
|
371 |
|
372 |
# Generate the descriptive text using the model
|
373 |
-
result = table_to_text(
|
374 |
|
375 |
return result
|
376 |
# Global variable
|
@@ -429,7 +432,7 @@ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
|
|
429 |
- Select two Excel files and a sheet name.
|
430 |
- For the two selected tables, compute the difference of the cumulative adverse growth rate over their respective three years for the selected sheet name (topic).
|
431 |
- For the selected topic (sheet name), find related sentences in the associated PDF text that mention the topic, and classify them by sentiment.
|
432 |
-
- For a selected country and topic, describe the adverse growth rate trend over three years using the [**google/flan-t5-
|
433 |
""")
|
434 |
with gr.Tab("Financial Report Text Analysis"):
|
435 |
gr.Markdown("## Financial Report Paragraph Selection and Analysis on Adverse Macro-Economy Scenario")
|
|
|
182 |
historical_col = f'Historical {year - 1}'
|
183 |
baseline_cols = [f'Baseline {year}', f'Baseline {year + 1}', f'Baseline {year + 2}']
|
184 |
adverse_cols = [f'Adverse {year}', f'Adverse {year + 1}', f'Adverse {year + 2}']
|
185 |
+
adverse_cols = [f'{year}', f'{year + 1}', f'{year + 2}']
|
186 |
level_deviation_col = f'Level Deviation {year + 2}'
|
187 |
|
188 |
# Drop rows and reset index
|
|
|
197 |
else:
|
198 |
raise ValueError(f"Expected {len(new_columns)} columns, but found {len(df.columns)} columns in the data.")
|
199 |
columns = ['Country', f'Adverse {year}', f'Adverse {year+1}', f'Adverse {year+2}', 'Adverse Cumulative']
|
200 |
+
columns = ['Country', f'{year}', f'{year+1}', f'{year+2}', 'Cumulative']
|
201 |
return df, df[columns]
|
202 |
|
203 |
# Process both files
|
|
|
354 |
Given the following adverse growth data for {theme} in {country}:
|
355 |
|
356 |
{row_str}
|
357 |
+
Topic: {theme}
|
358 |
|
359 |
Describe the yearly changes in adverse growth, highlighting whether the values increased or decreased, and provide the cumulative growth. Follow this example:
|
360 |
|
|
|
373 |
"""
|
374 |
|
375 |
# Generate the descriptive text using the model
|
376 |
+
result = table_to_text(prompt1, max_length=240, temperature = 0.7, top_p = 0.3, do_sample = False)[0]['generated_text']
|
377 |
|
378 |
return result
|
379 |
# Global variable
|
|
|
432 |
- Select two Excel files and a sheet name.
|
433 |
- For the two selected tables, compute the difference of the cumulative adverse growth rate over their respective three years for the selected sheet name (topic).
|
434 |
- For the selected topic (sheet name), find related sentences in the associated PDF text that mention the topic, and classify them by sentiment.
|
435 |
+
- For a selected country and topic, describe the adverse growth rate trend over three years using the [**google/flan-t5-xl**](https://huggingface.co/google/flan-t5-xl).
|
436 |
""")
|
437 |
with gr.Tab("Financial Report Text Analysis"):
|
438 |
gr.Markdown("## Financial Report Paragraph Selection and Analysis on Adverse Macro-Economy Scenario")
|