Skip to content

Instantly share code, notes, and snippets.

@rajacsp
Created February 10, 2019 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajacsp/911727a241f8a7c483e57060250ff08b to your computer and use it in GitHub Desktop.
Save rajacsp/911727a241f8a7c483e57060250ff08b to your computer and use it in GitHub Desktop.
from nltk.sentiment.vader import SentimentIntensityAnalyzer
sid = SentimentIntensityAnalyzer()
def get_sentiment(sentence):
sentiment_score = sid.polarity_scores(sentence)
positive_meter = round((sentiment_score['pos'] * 10), 2)
negative_meter = round((sentiment_score['neg'] * 10), 2)
return positive_meter, negative_meter
sentence = """
Jenny is one of the most dedicated and persistent software developers that I have encountered. She has a laser focus on quality and timelines, and can be counted on to deliver without fail.
Jenny is a person with razor sharp focus and very high dedication. She is very hard working and keeps detailed knowledge of whatever she is working on. She is also an advocate of technical/business improvements whenever she finds one. Overall she proved to be a valuable asset to the team. We used to keep looking to her for any detail on our platform - Just name it and she knows it.
"""
positive_meter, negative_meter = get_sentiment(sentence)
print("Positive", positive_meter)
print("Negative", negative_meter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment