Cachoups commited on
Commit
9c67e28
·
verified ·
1 Parent(s): e83043c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -10
app.py CHANGED
@@ -200,7 +200,10 @@ def process_pdfs_and_analyze_sentiment(file1, file2, sheet):
200
  def generate_text(df, country, theme):
201
  # Filter the dataframe based on the country
202
  row = df[df['Country'] == country].iloc[0]
203
-
 
 
 
204
  # Convert the row to a string format for prompt
205
  row_str = row.to_string(index=True)
206
 
@@ -211,21 +214,34 @@ def generate_text(df, country, theme):
211
  Summarize the adverse growth for {theme} in {country}. Highlight any increase or decrease compared to previous years and include the cumulative result.
212
  """
213
  prompt = f"""
214
- Here is an example of how to summarize adverse growth data for a given country:
 
 
215
  Country: Australia
216
- Adverse 2020: -0.427975
217
- Adverse 2021: -1.987167
218
- Adverse 2022: -1.195906
219
- Adverse Cumulative: -3.573762
220
  The topic is GDP.
221
 
222
  Summary:
223
- In the adverse scenario, the growth for GDP in Australia decreased by -0.427975% in 2020, worsened further by -1.987167% in 2021, and slightly improved by -1.195906% in 2022, resulting in an adverse cumulative decrease of -3.573762%.
224
-
 
 
 
 
 
 
 
 
 
 
 
225
  Now, use the following data for {theme} in {country} to generate a similar summary:
226
  {row_str}
227
- The topic is {theme}.
228
- Summarize and ensure that the summary reflects the theme accurately and follows the pattern from the example. Use terms 'increase' and 'decrease' to describe changes in values. Make sure the output aligns with the provided data.
229
  """
230
 
231
 
 
200
  def generate_text(df, country, theme):
201
  # Filter the dataframe based on the country
202
  row = df[df['Country'] == country].iloc[0]
203
+ for column in df.columns:
204
+ if column != 'Country':
205
+ df[column] = df[column].apply(lambda x: f"{x:.6f}%")
206
+
207
  # Convert the row to a string format for prompt
208
  row_str = row.to_string(index=True)
209
 
 
214
  Summarize the adverse growth for {theme} in {country}. Highlight any increase or decrease compared to previous years and include the cumulative result.
215
  """
216
  prompt = f"""
217
+ Here are two examples of how to summarize adverse growth data for a given country:
218
+
219
+ Example 1 (Australia - GDP):
220
  Country: Australia
221
+ Adverse 2020: -0.427975%
222
+ Adverse 2021: -1.987167%
223
+ Adverse 2022: -1.195906%
224
+ Adverse Cumulative: -3.573762%
225
  The topic is GDP.
226
 
227
  Summary:
228
+ In the adverse scenario, the growth for GDP in Australia decreased by 0.427975% in 2020, worsened further by 1.987167% in 2021, and slightly improved by 1.195906% in 2022, resulting in an adverse cumulative decrease of 3.573762%.
229
+
230
+ Example 2 (Poland - HICP):
231
+ Country: Poland
232
+ Adverse 2023: 17.656378%
233
+ Adverse 2024: 8.188389%
234
+ Adverse 2025: 4.321625%
235
+ Adverse Cumulative: 32.79156%
236
+ The topic is HICP.
237
+
238
+ Summary:
239
+ In the adverse scenario, the HICP rate in Poland was 17.656378% in 2023, decreased to 8.188389% in 2024, and continued to decrease to 4.321625% in 2025. The cumulative adverse HICP rate over the period is 32.79156%.
240
+
241
  Now, use the following data for {theme} in {country} to generate a similar summary:
242
  {row_str}
243
+
244
+ The topic is {theme}. Summarize the data, ensuring that the summary reflects the theme accurately. Follow the pattern of the examples provided and describe any changes in values using terms like 'increase' and 'decrease'. Make sure the output aligns with the data.
245
  """
246
 
247