ELONISEVIL / amfora

1 stars 0 forks source link

Patch-1 #10

Open ELONISEVIL opened 2 months ago

ELONISEVIL commented 2 months ago

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}")

Entry point of the script

if name == "main": main()