Skip to content

Instantly share code, notes, and snippets.

@SKaplanOfficial
Last active January 18, 2023 21:57
Show Gist options
  • Save SKaplanOfficial/d81392b7667305fbf799e1c463120602 to your computer and use it in GitHub Desktop.
Save SKaplanOfficial/d81392b7667305fbf799e1c463120602 to your computer and use it in GitHub Desktop.
Sentiment tagging with PyXA
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