import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
Download the VADER lexicon
nltk.download('vader_lexicon')
def main():
Initialize the SentimentIntensityAnalyzer
sid = SentimentIntensityAnalyzer()
# Get input text from the user
text = input("Enter a sentence: ")
# Compute sentiment scores
scores = sid.polarity_scores(text)
# Determine the sentiment based on the compound score
if scores['compound'] >= 0.05:
sentiment = "positive"
elif scores['compound'] <= -0.05:
sentiment = "negative"
else:
sentiment = "neutral"
# Display the sentiment
print(f"Sentiment: {sentiment}")
import nltk from nltk.sentiment.vader import SentimentIntensityAnalyzer
Download the VADER lexicon
nltk.download('vader_lexicon')
def main():
Initialize the SentimentIntensityAnalyzer
Entry point of the script
if name == "main": main()