from utils.file_processor import FileProcessor, ProcessorOptions import re from pathlib import Path class BoyRemovalProcessor(FileProcessor): def process_content(self, content: str) -> str: # Remove occurrences with comma and space content = re.sub(r',\s*([1-9]boy|[1-9]boys|[1-9]girl|[1-9]girls)', '', content) # Remove remaining occurrences content = re.sub(r'([1-9]boy|[1-9]boys|[1-9]girl|[1-9]girls)', '', content) # Clean up commas content = re.sub(r',\s*,', ',', content) # Remove double commas content = re.sub(r',\s*$', '', content) # Remove trailing comma content = re.sub(r'^\s*,', '', content) # Remove leading comma content = re.sub(r'\s*,\s*', ', ', content) # Normalize comma spacing return content def main(): options = ProcessorOptions( recursive=True, dry_run=False, file_extensions={'.txt'} ) processor = BoyRemovalProcessor(options) processor.process_directory(Path('.')) if __name__ == "__main__": main()