darthPanda commited on
Commit
2c8c228
1 Parent(s): 41dac9c
Files changed (1) hide show
  1. app.py +31 -11
app.py CHANGED
@@ -226,8 +226,12 @@ elif len(uploaded_file)>0:
226
  ############################ 3. Processing ############################
227
 
228
  ############################ 3.1. Sentiment Analysis ############################
 
 
 
229
  labels = ['neutral', 'positive', 'negative']
230
- values = df.label.value_counts().to_list()
 
231
 
232
  # removing words
233
  words_to_remove = ["s", "quarter", "thank", "million", "Thank", "quetion", 'wa', 'rate', 'firt',
@@ -268,9 +272,14 @@ elif len(uploaded_file)>0:
268
  if num_of_neu_sentences == 0:
269
  neu_df.loc[0] = [0.0, '-------No neutral sentences found in report-------']
270
 
 
 
 
271
  df_temp = neg_df
272
- df_temp = df_temp['score'] * -1
273
- df_temp = pd.concat([df_temp, pos_df])
 
 
274
 
275
  ############################ 3.2. Emotion Analysis ############################
276
 
@@ -313,10 +322,21 @@ elif len(uploaded_file)>0:
313
  if num_of_surprise_sentences == 0:
314
  df_surprise.loc[0] = [0.0, '-------No surprised sentences found in report-------']
315
 
 
 
 
 
 
316
  df_temp_emotion = df_sadness
317
- df_temp_emotion = pd.concat([df_sadness, df_anger])
318
- df_temp_emotion = df_temp_emotion['score'] * -1
319
- df_temp_emotion = pd.concat([df_temp_emotion, df_joy])
 
 
 
 
 
 
320
 
321
 
322
  ############################ 3.3. Intent Analysis ############################
@@ -427,7 +447,7 @@ elif len(uploaded_file)>0:
427
 
428
  fig.add_trace(go.Indicator(
429
  mode = "number",
430
- value = int(df_temp.score.mean()*100),
431
  number = {"suffix": "%"},
432
  title = {"text": "<span style='font-size:1.5em'>Sentiment Analysis</span><br><span style='font-size:0.8em;color:gray'>Positivity Score</span>"}
433
  ), row=4, col=3)
@@ -448,7 +468,7 @@ elif len(uploaded_file)>0:
448
 
449
  fig.add_trace(go.Indicator(
450
  mode = "gauge+number",
451
- value = df_temp.score.mean(),
452
  domain = {'x': [0, 1], 'y': [0, 1]},
453
  title = {'text': "Average of Score", 'font': {'size': 16}},
454
  gauge = {
@@ -467,9 +487,9 @@ elif len(uploaded_file)>0:
467
  }
468
  ), row=6, col=5)
469
 
470
- if df_temp.score.mean() < -0.29:
471
  fig.update_traces(title_text="Cummulative Sentiment Negative", selector=dict(type='indicator'), row=6, col=5)
472
- elif df_temp.score.mean() < 0.29:
473
  fig.update_traces(title_text="Cummulative Sentiment Neutral", selector=dict(type='indicator'), row=6, col=5)
474
  else:
475
  fig.update_traces(title_text="Cummulative Sentiment Positive", selector=dict(type='indicator'), row=6, col=5)
@@ -505,7 +525,7 @@ elif len(uploaded_file)>0:
505
 
506
  fig.add_trace(go.Indicator(
507
  mode = "number",
508
- value = int(df_temp_emotion.score.mean()*100),
509
  number = {"suffix": "%"},
510
  title = {"text": "<span style='font-size:1.5em'>Emotion Analysis</span><br><span style='font-size:0.8em;color:gray'>Happiness Score</span>"}
511
  ), row=26, col=3)
 
226
  ############################ 3. Processing ############################
227
 
228
  ############################ 3.1. Sentiment Analysis ############################
229
+ # labels = ['neutral', 'positive', 'negative']
230
+ # values = df.label.value_counts().to_list()
231
+
232
  labels = ['neutral', 'positive', 'negative']
233
+ values = [df[df['label']=='neutral'].shape[0], df[df['label']=='positive'].shape[0], df[df['label']=='negative'].shape[0]]
234
+
235
 
236
  # removing words
237
  words_to_remove = ["s", "quarter", "thank", "million", "Thank", "quetion", 'wa', 'rate', 'firt',
 
272
  if num_of_neu_sentences == 0:
273
  neu_df.loc[0] = [0.0, '-------No neutral sentences found in report-------']
274
 
275
+ # df_temp = neg_df
276
+ # df_temp = df_temp['score'] * -1
277
+ # df_temp = pd.concat([df_temp, pos_df])
278
  df_temp = neg_df
279
+ df_temp['score'] = df_temp['score'] * -1
280
+ df_temp_list = df_temp['score'].to_list() + pos_df['score'].to_list()
281
+
282
+ mean = sum(df_temp_list) / len(df_temp_list)
283
 
284
  ############################ 3.2. Emotion Analysis ############################
285
 
 
322
  if num_of_surprise_sentences == 0:
323
  df_surprise.loc[0] = [0.0, '-------No surprised sentences found in report-------']
324
 
325
+ # df_temp_emotion = df_sadness
326
+ # df_temp_emotion = pd.concat([df_sadness, df_anger])
327
+ # df_temp_emotion = df_temp_emotion['score'] * -1
328
+ # df_temp_emotion = pd.concat([df_temp_emotion, df_joy])
329
+
330
  df_temp_emotion = df_sadness
331
+ df_temp_emotion['score'] = df_temp_emotion['score'] * -1
332
+ df_temp_emotion_list = df_temp_emotion['score'].to_list() + df_joy['score'].to_list()
333
+ emotion_mean = sum(df_temp_emotion_list) / len(df_temp_emotion_list)
334
+
335
+ # df_temp = neg_df
336
+ # df_temp['score'] = df_temp['score'] * -1
337
+ # df_temp_list = df_temp['score'].to_list() + pos_df['score'].to_list()
338
+
339
+ # mean = sum(df_temp_list) / len(df_temp_list)
340
 
341
 
342
  ############################ 3.3. Intent Analysis ############################
 
447
 
448
  fig.add_trace(go.Indicator(
449
  mode = "number",
450
+ value = int(mean*100),
451
  number = {"suffix": "%"},
452
  title = {"text": "<span style='font-size:1.5em'>Sentiment Analysis</span><br><span style='font-size:0.8em;color:gray'>Positivity Score</span>"}
453
  ), row=4, col=3)
 
468
 
469
  fig.add_trace(go.Indicator(
470
  mode = "gauge+number",
471
+ value = mean,
472
  domain = {'x': [0, 1], 'y': [0, 1]},
473
  title = {'text': "Average of Score", 'font': {'size': 16}},
474
  gauge = {
 
487
  }
488
  ), row=6, col=5)
489
 
490
+ if mean < -0.29:
491
  fig.update_traces(title_text="Cummulative Sentiment Negative", selector=dict(type='indicator'), row=6, col=5)
492
+ elif mean < 0.29:
493
  fig.update_traces(title_text="Cummulative Sentiment Neutral", selector=dict(type='indicator'), row=6, col=5)
494
  else:
495
  fig.update_traces(title_text="Cummulative Sentiment Positive", selector=dict(type='indicator'), row=6, col=5)
 
525
 
526
  fig.add_trace(go.Indicator(
527
  mode = "number",
528
+ value = int(emotion_mean*100),
529
  number = {"suffix": "%"},
530
  title = {"text": "<span style='font-size:1.5em'>Emotion Analysis</span><br><span style='font-size:0.8em;color:gray'>Happiness Score</span>"}
531
  ), row=26, col=3)