INNER CODE UNIT · Python

get_traditional_sentiment

meetbryce/open-source-slack-ai · ossai/sentiment.py:31

def get_traditional_sentiment(text: str) -> dict:
    """
    Calculate sentiment polarity scores using NLTK's VADER sentiment analyzer.
    
    Args:
        text (str): The text to analyze for sentiment
        
    Returns:
        dict: A dictionary containing sentiment scores with keys:
            - 'neg': Negative sentiment score (0.0 to 1.0)
            - 'neu': Neutral sentiment score (0.0 to 1.0)  
            - 'pos': Positive sentiment score (0.0 to 1.0)
            - 'compound': Compound score (-1.0 to 1.0)
    """
    if not text or not text.strip():
        # Return neutral scores for empty or whitespace-only text
        return {'neg': 0.0, 'neu': 1.0, 'pos': 0.0, 'compound': 0.0}
    

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…