Created
April 26, 2021 22:51
-
-
Save idcesares/4b789a64e91a43a96d4f8a2f999b0e2e to your computer and use it in GitHub Desktop.
Simple Sentiment Analysis using TextBlob Python Library. Only available in english.
This file contains hidden or 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
| from textblob import TextBlob | |
| def sentiment(text): | |
| base_text = TextBlob(text) | |
| sentiment_score = base_text.sentiment.polarity | |
| if sentiment_score < 0: | |
| return 'Negative' | |
| elif sentiment_score == 0: | |
| return 'Neutral' | |
| return 'Positive' | |
| result = sentiment("I'm very happy") | |
| print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment