app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer def sentiment_scores(sentence): sid_obj = SentimentIntensityAnalyzer() sentiment_dict = sid_obj.polarity_scores(sentence) print(f"Sentiment Scores: {sentiment_dict}") print(f"Negative Sentiment: {sentiment_dict['neg']*100}%") print(f"Neutral Sentiment: {sentiment_dict['neu']*100}%") print(f"Positive Sentiment: {sentiment_dict['pos']*100}%") if sentiment_dict['compound'] >= 0.05: print("Overall Sentiment: Positive") elif sentiment_dict['compound'] <= -0.05: print("Overall Sentiment: Negative") else: print("Overall Sentiment: Neutral") if __name__ == "__main__": print("\n1st Statement:") sentence = "I know in my heart nobody comes close to me I am the greatest player in the world." sentiment_scores(sentence) print("\n2nd Statement:") sentence = "Shweta played well in the match as usual." sentiment_scores(sentence) print("\n3rd Statement:") sentence = "I am feeling sad today." sentiment_scores(sentence) |