Last active
January 18, 2023 21:57
-
-
Save SKaplanOfficial/d81392b7667305fbf799e1c463120602 to your computer and use it in GitHub Desktop.
Sentiment tagging with PyXA
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
import PyXA # Version 0.2.0 | |
# Use the default sentiment scale | |
text = PyXA.XAText("This sucks.\nBut this is great!") | |
print(text.tag_sentiments()) | |
# [('This sucks.\n', 'Negative'), ('But this is great!', 'Positive')] | |
# Use a custom sentiment scale | |
text = PyXA.XAText("This sucks.\nBut this is good!\nAnd this is great!") | |
print(text.tag_sentiments(sentiment_scale=["Very Negative", "Negative", "Somewhat Negative", "Neutral", "Somewhat Positive", "Positive", "Very Positive"])) | |
# [('This sucks.\n', 'Very Negative'), ('But this is good!\n', 'Neutral'), ('And this is great!', 'Very Positive')] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment