"""
TextDataCleaner
Generated by Eden via recursive self-improvement
2025-10-28 08:31:07.454396
"""

class TextDataCleaner:
    """
    A class to clean and sanitize text data by removing unwanted characters 
    and normalizing spacing. Useful for preprocessing textual data before
    further analysis or machine learning tasks.
    
    Methods:
        remove_special_chars(): Removes all special characters from the text.
        remove_digits(): Removes all digits from the text.
        clean_text(): Applies all cleaning operations and returns cleaned text.
    """

    def __init__(self, input_text: str):
        """Initializes with raw text to be cleaned."""
        self.text = input_text

    def remove_special_chars(self) -> str:
        """
        Removes all non-alphanumeric characters from the text.
        
        Returns:
            The text with special characters removed.
        """
        import re
        return re.sub(r'[^\w\s]', '', self.text)

    def remove_digits(self) -> str:
        """
        Removes all digits from the text.
        
        Returns:
            The text with digits removed.
        """
        return re.sub(r'\d+', '', self.text)

    def clean_text(self) -> str:
        """
        Applies all cleaning operations and returns cleaned text in lowercase
        with normalized whitespace.
        
        Returns:
            The sanitized text ready for analysis.
        """
        # Remove special characters
        cleaned = self.remove_special_chars()
        # Remove digits
        cleaned = self.remove_digits()
        # Convert to lowercase
        cleaned = cleaned.lower()
        # Replace multiple spaces with a single space and strip whitespace
        cleaned = ' '.join(cleaned.split())
        return cleaned

# Example usage:
if __name__ == "__main__":
    raw_text = "Hello! This is a test string. 123456789, special chars: @#$%^&*()"
    cleaner = TextDataCleaner(raw_text)
    
    # Clean the text
    cleaned_text = cleaner.clean_text()
    
    print("Raw text:", raw_text)
    print("\nCleaned text:", cleaned_text)