analyze_sentiment

analyze_sentiment(sentence)

Analyze the sentiment of the preprocessed user input using VADER sentiment analysis.

This function performs sentiment analysis on a given string and returns sentiment scores. It validates the input to ensure it meets specific requirements: must be a non-empty string containing at least one alphanumeric character and no emojis.

Parameters

Name Type Description Default
sentence str The input string to analyze. Must be non-empty, contain at least one alphanumeric character, and cannot contain emojis. required

Returns

Name Type Description
dict The sentiment analysis result. - neg : Negative sentiment score on a scale fro 0 to 1 (1 being the most negative) - neu: Neutral sentiment score on a scale fro 0 to 1 (1 being the most neutral) - pos: Positive sentiment score on a scale fro 0 to 1 (1 being the most positive) - compound: Compound sentiment (How positive or negative the input text is overall) on a scale from -1 to 1 (-1 being most negative, 1 being most positive)

Examples

>>> analyze_sentiment("I absolutely love Kpop")
{'neg': 0.0, 'neu': 0.315, 'pos': 0.685, 'compound': 0.7844}