diff --git a/sentimentanalysis.py b/sentimentanalysis.py index 447a451..051f348 100644 --- a/sentimentanalysis.py +++ b/sentimentanalysis.py @@ -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)