0% found this document useful (0 votes)
6 views1 page

Emotion Code

The document contains a Python script that performs sentiment analysis on a list of product reviews using the TextBlob library. It classifies each review as Positive, Negative, or Neutral based on the sentiment polarity. The script outputs the review along with its corresponding sentiment classification.

Uploaded by

anitha.chattu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Emotion Code

The document contains a Python script that performs sentiment analysis on a list of product reviews using the TextBlob library. It classifies each review as Positive, Negative, or Neutral based on the sentiment polarity. The script outputs the review along with its corresponding sentiment classification.

Uploaded by

anitha.chattu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

from textblob import TextBlob

# List of product reviews

reviews = [

"This product is amazing and works perfectly",

"Very bad quality, I am disappointed",

"The product is okay, not too good or bad",

"Excellent quality and fast delivery",

"Worst experience ever"

# Function for sentiment analysis

def analyze_sentiment(review):

analysis = TextBlob(review)

polarity = [Link]

if polarity > 0:

return "Positive"

elif polarity < 0:

return "Negative"

else:

return "Neutral"

# Analyze each review

for review in reviews:

sentiment = analyze_sentiment(review)

print(f"Review: {review}")

print(f"Emotion: {sentiment}\n")

You might also like