Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Sentimental Analysis

Sara Dokmak

Sentiment analysis, also known as opinion mining, is the process of computationally


determining the sentiment or emotional tone expressed in a piece of text, such as positive,
negative, or neutral.
To make sentimental analysis you can use various libraries such as: NLTK (Natural Language
Toolkit), TextBlob, VADER , spaCy, Stanford CoreNLP.
In this project I’ll be applying sentimental analysis using the two libraries VADER and TextBlob.
VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based
sentiment analysis tool specifically designed for sentiment analysis of social media text. We
import the `SentimentIntensityAnalyzer` class from `vaderSentiment.vaderSentiment` to
perform sentiment analysis using VADER. We calculate the compound score from the
`polarity_scores` method, which gives an overall sentiment polarity ranging from -1 to 1, where
-1 represents extremely negative sentiment, 1 represents extremely positive sentiment, and 0
represents neutral sentiment.
TextBlob is a Python library that provides a straightforward and intuitive way to perform
sentiment analysis. With its built-in sentiment analysis feature, TextBlob allows you to analyze
the sentiment polarity of text, ranging from negative to positive, and even identify neutral
sentiment. By leveraging a pre-trained machine learning model, TextBlob simplifies the process
of sentiment analysis, making it accessible to both beginners and experienced developers. Its
integration with NLTK resources and the simplicity of its API make TextBlob a popular choice for
sentiment analysis tasks in natural language processing applications.

Here is the python code:


from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
from textblob import TextBlob

# Define the paragraph to analyze


paragraph = "I had a great day today. The weather was beautiful, and I spent the day with my
friends. We had a lot of fun together."
# Perform sentiment analysis using VADER
vader_analyzer = SentimentIntensityAnalyzer()
vader_scores = vader_analyzer.polarity_scores(paragraph)
vader_compound_score = vader_scores['compound']

# Perform sentiment analysis using TextBlob


blob = TextBlob(paragraph)
textblob_sentiment = blob.sentiment.polarity

# Print the results


print("VADER Compound Score:", vader_compound_score)
print("TextBlob Sentiment Polarity:", textblob_sentiment)print("spaCy Sentiment Polarity:",
spacy_sentiment)

You might also like