Spaces:
Runtime error
Runtime error
Commit ·
2c8c228
1
Parent(s): 41dac9c
hf7
Browse files225 unmodified lines22622722822923023123223334 unmodified lines26826927027127227327427527636 unmodified lines313314315316317318319320321322104 unmodified lines42742842943043143243314 unmodified lines44844945045145245345412 unmodified lines46746846947047147247347447529 unmodified lines505506507508509510511225 unmodified lines############################ 3. Processing ######################################################## 3.1. Sentiment Analysis ############################labels = ['neutral', 'positive', 'negative']values = df.label.value_counts().to_list()# removing wordswords_to_remove = ["s", "quarter", "thank", "million", "Thank", "quetion", 'wa', 'rate', 'firt',34 unmodified linesif num_of_neu_sentences == 0:neu_df.loc[0] = [0.0, '-------No neutral sentences found in report-------']df_temp = neg_dfdf_temp = df_temp['score'] * -1df_temp = pd.concat([df_temp, pos_df])############################ 3.2. Emotion Analysis ############################36 unmodified linesif num_of_surprise_sentences == 0:df_surprise.loc[0] = [0.0, '-------No surprised sentences found in report-------']df_temp_emotion = df_sadnessdf_temp_emotion = pd.concat([df_sadness, df_anger])df_temp_emotion = df_temp_emotion['score'] * -1df_temp_emotion = pd.concat([df_temp_emotion, df_joy])############################ 3.3. Intent Analysis ############################104 unmodified linesfig.add_trace(go.Indicator(mode = "number",value = int(df_temp.score.mean()*100),number = {"suffix": "%"},title = {"text": "<span style='font-size:1.5em'>Sentiment Analysis</span><br><span style='font-size:0.8em;color:gray'>Positivity Score</span>"}), row=4, col=3)14 unmodified linesfig.add_trace(go.Indicator(mode = "gauge+number",value = df_temp.score.mean(),domain = {'x': [0, 1], 'y': [0, 1]},title = {'text': "Average of Score", 'font': {'size': 16}},gauge = {12 unmodified lines}), row=6, col=5)if df_temp.score.mean() < -0.29:fig.update_traces(title_text="Cummulative Sentiment Negative", selector=dict(type='indicator'), row=6, col=5)elif df_temp.score.mean() < 0.29:fig.update_traces(title_text="Cummulative Sentiment Neutral", selector=dict(type='indicator'), row=6, col=5)else:fig.update_traces(title_text="Cummulative Sentiment Positive", selector=dict(type='indicator'), row=6, col=5)29 unmodified linesfig.add_trace(go.Indicator(mode = "number",value = int(df_temp_emotion.score.mean()*100),number = {"suffix": "%"},title = {"text": "<span style='font-size:1.5em'>Emotion Analysis</span><br><span style='font-size:0.8em;color:gray'>Happiness Score</span>"}), row=26, col=3)225 unmodified lines22622722822923023123223323423523623734 unmodified lines27227327427527627727827928028128228328428536 unmodified lines322323324325326327328329330331332333334335336337338339340341342104 unmodified lines44744844945045145245314 unmodified lines46846947047147247347412 unmodified lines48748848949049149249349449529 unmodified lines525526527528529530531225 unmodified lines############################ 3. Processing ######################################################## 3.1. Sentiment Analysis ############################# labels = ['neutral', 'positive', 'negative']# values = df.label.value_counts().to_list()labels = ['neutral', 'positive', 'negative']values = [df[df['label']=='neutral'].shape[0], df[df['label']=='positive'].shape[0], df[df['label']=='negative'].shape[0]]# removing wordswords_to_remove = ["s", "quarter", "thank", "million", "Thank", "quetion", 'wa', 'rate', 'firt',34 unmodified linesif num_of_neu_sentences == 0:neu_df.loc[0] = [0.0, '-------No neutral sentences found in report-------']# df_temp = neg_df# df_temp = df_temp['score'] * -1# df_temp = pd.concat([df_temp, pos_df])df_temp = neg_dfdf_temp['score'] = df_temp['score'] * -1df_temp_list = df_temp['score'].to_list() + pos_df['score'].to_list()mean = sum(df_temp_list) / len(df_temp_list)############################ 3.2. Emotion Analysis ############################36 unmodified linesif num_of_surprise_sentences == 0:df_surprise.loc[0] = [0.0, '-------No surprised sentences found in report-------']# df_temp_emotion = df_sadness# df_temp_emotion = pd.concat([df_sadness, df_anger])# df_temp_emotion = df_temp_emotion['score'] * -1# df_temp_emotion = pd.concat([df_temp_emotion, df_joy])df_temp_emotion = df_sadnessdf_temp_emotion['score'] = df_temp_emotion['score'] * -1df_temp_emotion_list = df_temp_emotion['score'].to_list() + df_joy['score'].to_list()emotion_mean = sum(df_temp_emotion_list) / len(df_temp_emotion_list)# df_temp = neg_df# df_temp['score'] = df_temp['score'] * -1# df_temp_list = df_temp['score'].to_list() + pos_df['score'].to_list()# mean = sum(df_temp_list) / len(df_temp_list)############################ 3.3. Intent Analysis ############################104 unmodified linesfig.add_trace(go.Indicator(mode = "number",value = int(mean*100),number = {"suffix": "%"},title = {"text": "<span style='font-size:1.5em'>Sentiment Analysis</span><br><span style='font-size:0.8em;color:gray'>Positivity Score</span>"}), row=4, col=3)14 unmodified linesfig.add_trace(go.Indicator(mode = "gauge+number",value = mean,domain = {'x': [0, 1], 'y': [0, 1]},title = {'text': "Average of Score", 'font': {'size': 16}},gauge = {12 unmodified lines}), row=6, col=5)if mean < -0.29:fig.update_traces(title_text="Cummulative Sentiment Negative", selector=dict(type='indicator'), row=6, col=5)elif mean < 0.29:fig.update_traces(title_text="Cummulative Sentiment Neutral", selector=dict(type='indicator'), row=6, col=5)else:fig.update_traces(title_text="Cummulative Sentiment Positive", selector=dict(type='indicator'), row=6, col=5)29 unmodified linesfig.add_trace(go.Indicator(mode = "number",value = int(emotion_mean*100),number = {"suffix": "%"},title = {"text": "<span style='font-size:1.5em'>Emotion Analysis</span><br><span style='font-size:0.8em;color:gray'>Happiness Score</span>"}), row=26, col=3)
app.py+31-11