Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created January 31, 2021 07:44
Embed
What would you like to do?
nltk.download('vader_lexicon')
sid = SentimentIntensityAnalyzer()
sentiment = []
sentiment2 = []
for sent in sents:
sent1 = sent
sent_scores = sid.polarity_scores(sent1)
for x, y in sent_scores.items():
sentiment2.append((x, y))
sentiment.append((sent1, sent_scores))
# print(sentiment)
# sentiment
cols = ['sentence', 'numbers']
result = pd.DataFrame(sentiment, columns=cols)
print("First five rows of results: ", result.head())
# sentiment2
cols2 = ['label', 'values']
result2 = pd.DataFrame(sentiment2, columns=cols2)
print("First five rows of results2: ", result2.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment