Commit bc4d2e23 authored by Dhananjaya Jayashanka's avatar Dhananjaya Jayashanka

Updated textAnalyze(NLTK).py (sentiment analyzing)

parent 9b8f606a
This diff is collapsed.
......@@ -33,21 +33,22 @@ with open('emotions.txt', 'r') as file:
word, emotion = clear_line.split(':')
def sentiment_analyse(sentiment_text):
score = SentimentIntensityAnalyzer().polarity_scores(sentiment_text)
print(emotion)
print(score)
if score['neg'] > score['pos']:
print("Negative Sentiment")
elif score['neg'] < score['pos']:
print("Positive Sentiment")
else:
print("Neutral Sentiment")
sentiment_analyse(emotion)
if word in lemma_words:
emotion_list.append(emotion)
def sentiment_analyse(sentiment_text):
score = SentimentIntensityAnalyzer().polarity_scores(sentiment_text)
print(word)
print(score)
if score['neg'] > score['pos']:
print("Negative Sentiment")
emotion_list.append(emotion)
elif score['neg'] < score['pos']:
print("Positive Sentiment")
emotion_list.append(emotion)
else:
print("Neutral Sentiment")
emotion_list.append(emotion)
sentiment_analyse(word)
print(emotion_list)
w = Counter(emotion_list)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment