darthPanda commited on
Commit
fcd94b5
1 Parent(s): 82ffb8c
Files changed (1) hide show
  1. app.py +30 -0
app.py CHANGED
@@ -167,6 +167,7 @@ elif len(uploaded_file)>0:
167
 
168
  ############################ 3. Processing ############################
169
 
 
170
  labels = ['neutral', 'positive', 'negative']
171
  values = df.label.value_counts().to_list()
172
 
@@ -204,7 +205,36 @@ elif len(uploaded_file)>0:
204
  df_temp = df_temp['score'] * -1
205
  df_temp = pd.concat([df_temp, pos_df])
206
 
 
207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  ############################ 4. Plotting ############################
209
 
210
  fig = make_subplots(
 
167
 
168
  ############################ 3. Processing ############################
169
 
170
+ ############################ 3.1. Sentiment Analysis ############################
171
  labels = ['neutral', 'positive', 'negative']
172
  values = df.label.value_counts().to_list()
173
 
 
205
  df_temp = df_temp['score'] * -1
206
  df_temp = pd.concat([df_temp, pos_df])
207
 
208
+ ############################ 3.2. Emotion Analysis ############################
209
 
210
+ df_emotion = pd.DataFrame.from_dict(output_emotion)
211
+ df_emotion['Sentence']= pd.Series(useful_sentence)
212
+
213
+ df_joy = df_emotion[df_emotion['label']=='joy']
214
+ df_joy = df_joy[['score', 'Sentence']]
215
+ df_joy = df_joy.sort_values('score', ascending=False)
216
+ df_joy['score'] = df_joy['score'].round(4)
217
+ df_joy.rename(columns = {'Sentence':'Happy Sentences'}, inplace = True)
218
+
219
+ df_sadness = df_emotion[df_emotion['label']=='sadness']
220
+ df_sadness = df_sadness[['score', 'Sentence']]
221
+ df_sadness = df_sadness.sort_values('score', ascending=False)
222
+ df_sadness['score'] = df_sadness['score'].round(4)
223
+ df_sadness.rename(columns = {'Sentence':'Sad Sentences'}, inplace = True)
224
+
225
+ df_anger = df_emotion[df_emotion['label']=='anger']
226
+ df_anger = df_anger[['score', 'Sentence']]
227
+ df_anger = df_anger.sort_values('score', ascending=False)
228
+ df_anger['score'] = df_anger['score'].round(4)
229
+ df_anger.rename(columns = {'Sentence':'Angry Sentences'}, inplace = True)
230
+
231
+ df_surprise = df_emotion[df_emotion['label']=='surprise']
232
+ df_surprise = df_surprise[['score', 'Sentence']]
233
+ df_surprise = df_surprise.sort_values('score', ascending=False)
234
+ df_surprise['score'] = df_surprise['score'].round(4)
235
+ df_surprise.rename(columns = {'Sentence':'Surprised Sentences'}, inplace = True)
236
+
237
+
238
  ############################ 4. Plotting ############################
239
 
240
  fig = make_subplots(