"""
SentimentAnalysisPipeline
Generated by Eden via recursive self-improvement
2025-10-31 20:56:00.376361
"""

import pandas as pd
from transformers import pipeline

class SentimentAnalysisPipeline:
    """
    SentimentAnalysisPipeline is a Python class that provides a simplified interface to perform sentiment analysis on text data.
    
    The class uses the Hugging Face Transformers library's built-in `pipeline` function, which leverages pre-trained models for high-accuracy sentiment classification.
    """

    def __init__(self):
        self.sentiment_pipeline = pipeline("sentiment-analysis")

    def analyze_sentiment(self, text: str) -> pd.Series:
        """
        Analyzes the sentiment of a given text and returns a pandas Series with the label and score.

        Parameters:
            - text (str): The text to be analyzed for sentiment.

        Returns:
            - pd.Series: A series containing the predicted label ('POSITIVE', 'NEGATIVE', or 'NEUTRAL') and its confidence score.
        """
        result = self.sentiment_pipeline(text)[0]
        return pd.Series([result['label'], result['score']])

    def classify_sentiment(self, text: str) -> str:
        """
        Classifies the sentiment of a given text into one of three categories: positive, neutral, or negative.

        Parameters:
            - text (str): The text to be classified for its overall sentiment.

        Returns:
            - str: A string indicating the predicted sentiment category ('POSITIVE', 'NEGATIVE', or 'NEUTRAL').
        """
        result = self.sentiment_pipeline(text)[0]
        return result['label']

# Example usage
if __name__ == "__main__":
    # Initialize the sentiment analysis pipeline
    sa_pipeline = SentimentAnalysisPipeline()
    
    # Analyze and classify sentiment for a sample text
    example_text = "The weather is wonderful today, but I'm feeling quite down because my friend can't join me."
    print("Analyze sentiment:")
    sentiment_series = sa_pipeline.analyze_sentiment(example_text)
    print(sentiment_series)
    
    print("\nClassify sentiment:")
    sentiment_label = sa_pipeline.classify_sentiment(example_text)
    print(f"Sentiment: {sentiment_label}")