Spaces:
Runtime error
Runtime error
Commit ·
fcd94b5
1
Parent(s): 82ffb8c
hf2
Browse files166 unmodified lines16716816917017117217331 unmodified lines205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240166 unmodified lines
############################ 3. Processing ############################
############################ 3.1. Sentiment Analysis ############################ labels = ['neutral', 'positive', 'negative'] values = df.label.value_counts().to_list()
31 unmodified lines df_temp = df_temp['score'] * -1 df_temp = pd.concat([df_temp, pos_df])
############################ 3.2. Emotion Analysis ############################
df_emotion = pd.DataFrame.from_dict(output_emotion) df_emotion['Sentence']= pd.Series(useful_sentence)
df_joy = df_emotion[df_emotion['label']=='joy'] df_joy = df_joy[['score', 'Sentence']] df_joy = df_joy.sort_values('score', ascending=False) df_joy['score'] = df_joy['score'].round(4) df_joy.rename(columns = {'Sentence':'Happy Sentences'}, inplace = True)
df_sadness = df_emotion[df_emotion['label']=='sadness'] df_sadness = df_sadness[['score', 'Sentence']] df_sadness = df_sadness.sort_values('score', ascending=False) df_sadness['score'] = df_sadness['score'].round(4) df_sadness.rename(columns = {'Sentence':'Sad Sentences'}, inplace = True)
df_anger = df_emotion[df_emotion['label']=='anger'] df_anger = df_anger[['score', 'Sentence']] df_anger = df_anger.sort_values('score', ascending=False) df_anger['score'] = df_anger['score'].round(4) df_anger.rename(columns = {'Sentence':'Angry Sentences'}, inplace = True)
df_surprise = df_emotion[df_emotion['label']=='surprise'] df_surprise = df_surprise[['score', 'Sentence']] df_surprise = df_surprise.sort_values('score', ascending=False) df_surprise['score'] = df_surprise['score'].round(4) df_surprise.rename(columns = {'Sentence':'Surprised Sentences'}, inplace = True)
############################ 4. Plotting ############################
fig = make_subplots(app.py+30