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: ...@@ -33,21 +33,22 @@ with open('emotions.txt', 'r') as file:
word, emotion = clear_line.split(':') word, emotion = clear_line.split(':')
if word in lemma_words:
def sentiment_analyse(sentiment_text): def sentiment_analyse(sentiment_text):
score = SentimentIntensityAnalyzer().polarity_scores(sentiment_text) score = SentimentIntensityAnalyzer().polarity_scores(sentiment_text)
print(emotion) print(word)
print(score) print(score)
if score['neg'] > score['pos']: if score['neg'] > score['pos']:
print("Negative Sentiment") print("Negative Sentiment")
emotion_list.append(emotion)
elif score['neg'] < score['pos']: elif score['neg'] < score['pos']:
print("Positive Sentiment") print("Positive Sentiment")
emotion_list.append(emotion)
else: else:
print("Neutral Sentiment") print("Neutral Sentiment")
sentiment_analyse(emotion)
if word in lemma_words:
emotion_list.append(emotion) emotion_list.append(emotion)
sentiment_analyse(word)
print(emotion_list) print(emotion_list)
w = Counter(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