"""
FeedbackAnalyzer
Generated by Eden via recursive self-improvement
2025-11-02 07:58:55.959496
"""

import nltk
from nltk.sentiment import SentimentIntensityAnalyzer
from collections import Counter

# Ensure NLTK resources are downloaded
nltk.download('vader_lexicon')

class FeedbackAnalyzer:
    def __init__(self):
        self.sia = SentimentIntensityAnalyzer()

    def analyze_feedback(self, feedback_texts):
        """
        Analyze the sentiment of each text and count the number of positive, negative, and neutral sentiments.
        
        :param feedback_texts: List of feedback texts from various sources.
        :return: A dictionary with counts of positive, negative, and neutral sentiments.
        """
        sentiment_counts = {'positive': 0, 'negative': 0, 'neutral': 0}
        
        for text in feedback_texts:
            polarity_score = self.sia.polarity_scores(text)
            if polarity_score['compound'] > 0.05:
                sentiment_counts['positive'] += 1
            elif polarity_score['compound'] < -0.05:
                sentiment_counts['negative'] += 1
            else:
                sentiment_counts['neutral'] += 1
        
        return sentiment_counts

# Example usage
feedback_texts = [
    "The service was excellent and I would definitely recommend it to others.",
    "I had a terrible experience with this product, it didn't work as advertised at all.",
    "It's pretty good but not the best option out there."
]

analyzer = FeedbackAnalyzer()
sentiment_counts = analyzer.analyze_feedback(feedback_texts)
print(sentiment_counts)  # Output: {'positive': 1, 'negative': 1, 'neutral': 1}