abc123 / hack /test_interactive_parsing.py
vimalk78's picture
feat(crossword): generated crosswords with clues
486eff6
raw
history blame
2.25 kB
#!/usr/bin/env python3
"""
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}")
# Simulate the parsing logic from interactive mode
parts = user_input.split()
# Handle quoted strings
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:
# Find where parameters start
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
# Join the input parts to look for comma separation
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 []
# Check multi-theme logic
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()