Vader is a rule-based sentiment analysis tool that works well for social media texts as well regular texts.
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyser = SentimentIntensityAnalyzer()
def print_sentiment_scores(tweets):
vadersenti = analyser.polarity_scores(tweets)
return pd.Series([vadersenti['pos'], vadersenti['neg'], vadersenti['neu'], vadersenti['compound']])
text = 'This goes beyond party lines. Separating families betrays our values as Texans, Americans and fellow human beings'
print_sentiment_scores(text)
The results are:
0 0.2470
1 0.0000
2 0.7530
3 0.5067
The compound score is computed by summing the valence scores of each word in the lexicon, adjusted according to the rules, and then normalized to be between -1 (most extreme negative) and +1 (most extreme positive). This is the most useful metric if you want a single unidimensional measure of sentiment for a given sentence. Calling it a 'normalized, weighted composite score' is accurate
Though positive sentiment is derived with the compound score >= 0.05, we always have an option to determine the positive, negative & neutrality of the sentence, by changing these scores
I personally find Vader Sentiment to figure out the sentiment based on the emotions, special characters, emojis very well.