| |
| """ |
| Test interactive parsing logic matches original behavior |
| """ |
|
|
| def test_interactive_parsing(): |
| print("🧪 Testing Interactive Command Parsing") |
| print("=" * 50) |
| |
| test_commands = [ |
| "I will always love you", |
| "cats, dogs, pets", |
| "\"I love you, moonpie, chocolate\"", |
| "science, technology 15", |
| "single_word", |
| ] |
| |
| for user_input in test_commands: |
| print(f"\n📝 Input: {user_input}") |
| |
| |
| parts = user_input.split() |
| |
| |
| if user_input.startswith('"') and '"' in user_input[1:]: |
| quote_end = user_input.index('"', 1) |
| quoted_content = user_input[1:quote_end] |
| remaining = user_input[quote_end + 1:].strip() |
| |
| if ',' in quoted_content: |
| inputs = [item.strip() for item in quoted_content.split(',') if item.strip()] |
| else: |
| inputs = [quoted_content] |
| |
| remaining_parts = remaining.split() if remaining else [] |
| else: |
| |
| param_keywords = ['tier', 'difficulty', 'multi'] |
| input_end = len(parts) |
| |
| for i, part in enumerate(parts): |
| if part.lower() in param_keywords or part.isdigit(): |
| input_end = i |
| break |
| |
| |
| input_text = ' '.join(parts[:input_end]) |
| remaining_parts = parts[input_end:] |
| |
| if ',' in input_text: |
| inputs = [item.strip() for item in input_text.split(',') if item.strip()] |
| else: |
| inputs = [input_text] if input_text.strip() else [] |
| |
| |
| clean_inputs = [inp.strip().lower() for inp in inputs if inp.strip()] |
| auto_multi_theme = len(clean_inputs) > 2 |
| |
| print(f" Parsed: {clean_inputs}") |
| print(f" Length: {len(clean_inputs)} -> Auto multi-theme: {auto_multi_theme}") |
|
|
| if __name__ == "__main__": |
| test_interactive_parsing() |