"""
SentimentAnalyzer
Generated by Eden via recursive self-improvement
2025-10-27 19:27:41.446524
"""

class SentimentAnalyzer:
    def __init__(self):
        self.positive_words = {
            "love": 5,
            "enjoy": 4,
            "good": 3,
            "happy": 4,
            "wonderful": 5,
            "great": 4,
            "awesome": 5
        }
        self.negative_words = {
            "hate": -5,
            "dislike": -4,
            "bad": -3,
            "sad": -4,
            "terrible": -5,
            "horrible": -5,
            "unhappy": -4
        }

    def add_positive_word(self, word, score=1):
        """Add a positive word to the lexicon with an optional score."""
        self.positive_words[word] = score

    def add_negative_word(self, word, score=-1):
        """Add a negative word to the lexicon with an optional score."""
        self.negative_words[word] = score

    def calculate_score(self, text):
        """Calculate the sentiment score of the given text."""
        words = text.lower().split()
        total_score = 0
        
        for word in words:
            if word in self.positive_words:
                total_score += self.positive_words[word]
            elif word in self.negative_words:
                total_score += self.negative_words[word]

        return total_score

    def evaluate_sentiment(self, text):
        """Evaluate the overall sentiment of the given text."""
        score = self.calculate_score(text)
        if score > 0:
            return "positive"
        elif score < 0:
            return "negative"
        else:
            return "neutral"

# Example usage
if __name__ == "__main__":
    analyzer = SentimentAnalyzer()
    
    # Test positive text
    text_positive = "I love this product and enjoy using it!"
    print(f"Text: '{text_positive}'")
    print(f"Sentiment: {analyzer.evaluate_sentiment(text_positive)}")  # Output: positive
    
    # Test negative text
    text_negative = "This service is terrible and very frustrating."
    print(f"\nText: '{text_negative}'")
    print(f"Sentiment: {analyzer.evaluate_sentiment(text_negative)}")  # Output: negative
    
    # Test neutral text
    text_neutral = "The weather is fine today."
    print(f"\nText: '{text_neutral}'")
    print(f"Sentiment: {analyzer.evaluate_sentiment(text_neutral)}")  # Output: neutral