Commit 9b8f606a authored by Dhananjaya Jayashanka's avatar Dhananjaya Jayashanka

Updated textAnalyze(NLTK).py (sentiment analyzing)

parent eb8bec91
......@@ -32,23 +32,26 @@ with open('emotions.txt', 'r') as file:
clear_line = line.replace("\n", '').replace(",", '').replace("'", '').strip()
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)
print(emotion_list)
w = Counter(emotion_list)
print(w)
def sentiment_analyse(sentiment_text):
score = SentimentIntensityAnalyzer().polarity_scores(sentiment_text)
if score['neg'] > score['pos']:
print("Negative Sentiment")
elif score['neg'] < score['pos']:
print("Positive Sentiment")
else:
print("Neutral Sentiment")
sentiment_analyse(cleaned_text)
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