Last active
December 17, 2019 20:20
-
-
Save glickmac/d589847d14ebe1f2e3cf4c982b900998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Chapter_Sentiment(Chapter_Text): | |
def Average(lst): | |
return float(sum(lst)) / len(lst) | |
sid = SentimentIntensityAnalyzer() | |
sentences = Chapter_Text.split('.') | |
sentiment_scores = [] | |
for item in sentences: | |
sentiment = sid.polarity_scores(item) | |
sentiment_value = sentiment['compound'] | |
sentiment_scores.append(sentiment_value) | |
return(Average(sentiment_scores)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment