"""
SentimentAnalysisCapability
Generated by Eden via recursive self-improvement
2025-11-01 16:43:59.218116
"""

import nltk
from nltk.sentiment import SentimentIntensityAnalyzer

class SentimentAnalysisCapability:
    def __init__(self):
        # Initialize the Sentiment Intensity Analyzer from NLTK library
        self.sia = SentimentIntensityAnalyzer()

    def analyze_sentiment(self, feedback_text: str) -> dict:
        """
        Analyzes the sentiment of a given text.
        
        Args:
            feedback_text (str): The user feedback or review to be analyzed.
        
        Returns:
            dict: A dictionary containing the sentiment scores for positive, negative, neutral, and compound sentiment.
                  {'positive': 0.32, 'negative': -0.15, 'neutral': 0.48, 'compound': 0.23}
        """
        return self.sia.polarity_scores(feedback_text)

    def categorize_sentiment(self, feedback_text: str) -> str:
        """
        Categorizes the sentiment of a given text into positive, negative, or neutral.
        
        Args:
            feedback_text (str): The user feedback or review to be analyzed.
        
        Returns:
            str: The categorized sentiment ('Positive', 'Negative', or 'Neutral').
        """
        scores = self.analyze_sentiment(feedback_text)
        if scores['compound'] > 0.05:
            return 'Positive'
        elif scores['compound'] < -0.05:
            return 'Negative'
        else:
            return 'Neutral'

# Example Usage
if __name__ == "__main__":
    # Initialize the SentimentAnalysisCapability instance
    sentiment_analyzer = SentimentAnalysisCapability()

    # Analyze a sample feedback text
    feedback_text = "The SAGE tool is very helpful, but it could use some updates."
    sentiment_scores = sentiment_analyzer.analyze_sentiment(feedback_text)
    print(f"Sentiment Scores: {sentiment_scores}")

    # Categorize the sentiment of the same feedback text
    categorized_sentiment = sentiment_analyzer.categorize_sentiment(feedback_text)
    print(f"Categorized Sentiment: {categorized_sentiment}")