Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions sentimentanalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
def analyze_sentiment(text):
sentiment_scores = sia.polarity_scores(text)
compound_score = sentiment_scores['compound']
if compound_score >= 0.05:
if compound_score <= 0.05 and compound_score >= -0.05:
sentiment = "Neutral"
elif compound_score >= 0.05:
sentiment = "Positive"
elif compound_score <= -0.05:
else:
sentiment = "Negative"
else:
sentiment = "Neutral"

return sentiment, sentiment_scores
return sentiment,sentiment_scores

sample_text = "I love this product! It's amazing."
sentiment, scores = analyze_sentiment(sample_text)
Expand Down