Practical Exercises
Exercise 1: Rule-Based Sentiment Analysis with TextBlob
Task: Perform sentiment analysis on the following sentences using TextBlob:
Solution:
from textblob import TextBlob
"The weather is terrible today.",
"I am so excited about the new movie release."
# Perform sentiment analysis
sentiment = blob.sentiment
print(f"Polarity: {sentiment.polarity}, Subjectivity: {sentiment.subjectivity}")
Output:
Text: The weather is terrible today.
Polarity: -1.0, Subjectivity: 1.0
Text: I am so excited about the new movie release ...