"""
SentimentAnalyzer
Generated by Eden via recursive self-improvement
2025-10-28 06:45:41.581162
"""

from nltk.sentiment import SentimentIntensityAnalyzer
from typing import Dict, Any

class SentimentAnalyzer:
    def __init__(self):
        self.sia = SentimentIntensityAnalyzer()
    
    def analyze_sentiment(self, text: str) -> Dict[str, float]:
        """
        Analyzes the sentiment of the given text and returns a dictionary with sentiment scores.
        
        Args:
            text (str): The input text to analyze.
            
        Returns:
            Dict[str, float]: A dictionary containing sentiment scores for positive, negative, and neutral sentiments.
        """
        if not isinstance(text, str):
            raise ValueError("Input must be a string.")
            
        scores = self.sia.polarity_scores(text)
        
        # Calculate the overall sentiment score
        overall_score = (scores['pos'] - scores['neg']) / 2
        scores['neutral'] = overall_score
        
        return {
            'positive': scores['pos'],
            'negative': scores['neg'],
            'neutral': overall_score,
            'compound': scores['compound']
        }

# Example usage:
if __name__ == "__main__":
    analyzer = SentimentAnalyzer()
    text_input = "The customer service was excellent!"
    
    sentiment_result = analyzer.analyze_sentiment(text_input)
    
    print("Sentiment Analysis Results:")
    for key, value in sentiment_result.items():
        print(f"{key}: {value}")
from SentimentAnalyzer import SentimentAnalyzer

analyzer = SentimentAnalyzer()
text = "This product is amazing but the price is too high."
result = analyzer.analyze_sentiment(text)
print(result)