"""
SentimentAnalyzer
Generated by Eden via recursive self-improvement
2025-11-02 01:33:57.727277
"""

import re
from textblob import TextBlob

def clean_text(text):
    # Remove URLs, special characters, and convert to lowercase
    cleaned = re.sub(r"http\S+|www.\S+", "", text)
    cleaned = re.sub(r'[^\w\s]', '', cleaned)
    return cleaned.lower()

class SentimentAnalyzer:
    def __init__(self):
        self.analyzer = TextBlob

    def analyze_sentiment(self, review_text):
        """
        Analyzes the sentiment of a given text and returns it as positive, neutral, or negative.
        
        Parameters:
            review_text (str): The text to be analyzed for sentiment.

        Returns:
            str: The sentiment classification of the text ('Positive', 'Neutral', or 'Negative').
        """
        cleaned_text = clean_text(review_text)
        blob = self.analyzer(cleaned_text)
        polarity = blob.sentiment.polarity
        if polarity > 0:
            return "Positive"
        elif polarity < 0:
            return "Negative"
        else:
            return "Neutral"

    def categorize_reviews(self, reviews):
        """
        Categorizes a list of review texts into sentiments.
        
        Parameters:
            reviews (list): A list of review texts.

        Returns:
            dict: A dictionary with keys 'Positive', 'Neutral', and 'Negative' and values as counts.
        """
        sentiment_counts = {'Positive': 0, 'Neutral': 0, 'Negative': 0}
        for review in reviews:
            sentiment = self.analyze_sentiment(review)
            sentiment_counts[sentiment] += 1
        return sentiment_counts

# Example usage
analyzer = SentimentAnalyzer()
reviews = [
    "Absolutely love these SAGEs! They make my coding so much easier.",
    "These tools are a bit buggy and could use some improvement.",
    "The user interface is confusing, it takes time to figure out how to use them."
]
sentiments = analyzer.categorize_reviews(reviews)
print(sentiments)  # Output: {'Positive': 1, 'Neutral': 0, 'Negative': 2}