Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python sentiment analysis libraries score text as positive, negative, or neutral. A lexicon-based scorer applies a fixed dictionary and rules rather than a trained neural model. These libraries let support tools, social media monitors, and AI agents measure how people feel about a product.
Popularity
Transformers has the most monthly downloads in this comparison, at 119.8M, a count that covers every model task in the library.
from transformers import pipeline
classifier = pipeline(model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
classifier("This movie is disgustingly good !")
def analyze(self, text):
"""Return the sentiment as a named tuple of the form:
``Sentiment(classification, p_pos, p_neg)``
"""
# Lazily train the classifier super().analyze(text)
tokens = word_tokenize(text, include_punc=False)
filtered = (t.lower() for t in tokens if len(t) >= 3)
feats = self.feature_extractor(filtered)
prob_dist = self._classifier.prob_classify(feats)
return self.RETURN_TYPE(
classification=prob_dist.max(),
p_pos=prob_dist.prob("pos"),
p_neg=prob_dist.prob("neg"),
)
TextBlob
Returns polarity and subjectivity scores and supports custom text classifiers.
Downloads / mo
3.2M
Stars
9.6K
Last release
0.20.1
License
MIT
Strengths
Separates polarity and subjectivity.Read sentiment direction and subjectivity as separate values.
Trains custom text classifiers.Train a classifier on custom labeled text examples.
Limitations
Analyzer choice changes returned values.NaiveBayesAnalyzer returns class probabilities instead of polarity and subjectivity.
Optional analyzer uses movie reviews.The built-in NaiveBayesAnalyzer is trained on a movie-review corpus.
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyzer = SentimentIntensityAnalyzer()
analyzer.polarity_scores("VADER is smart, handsome, and funny.")
from flair.data import Sentence
from flair.nn import Classifier
# make a sentencesentence = Sentence('I love Berlin .')
# load the NER taggertagger = Classifier.load('sentiment')
# run NER over sentencetagger.predict(sentence)
# print the sentence with all annotationsprint(sentence)
from pysentimiento import create_analyzer
analyzer = create_analyzer(task="sentiment", lang="es")
analyzer.predict("Qué gran jugador es Messi")
FAQ
Transformers suits applications that run or fine-tune pretrained sentiment classifiers. VADER suits social media text scored by a lexicon and rules. TextBlob suits code that needs separate polarity and subjectivity scores.
VADER is a lexicon and rule-based sentiment analysis tool attuned to sentiments expressed in social media. It returns a composite score alongside its category scores.
TextBlob returns separate polarity and subjectivity scores and trains custom text classifiers. VADER scores informal social media text with a lexicon and rules.
Flair loads sentiment models and trains text classifiers with configurable embeddings. Its standard sentiment model targets English with binary labels.
For coding agents
Found your sentiment analysis library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.