fixed with example data

This commit is contained in:
nmemmert committed 2025-11-06 12:32:37 -05:00
1 parent 5fb1a855a1
commit d28cccc957
16 files changed
+797

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
import re
# Test the specific failing case
test_text = 'FemaleBrookville HighMouse'
pattern = r'^(Female|Male)(.+?)([A-Z][a-z]+)$'
print(f"Testing: {test_text}")
print(f"Pattern: {pattern}")
match = re.match(pattern, test_text)
if match:
print("✅ MATCH!")
print(f"Groups: {match.groups()}")
print(f"Group 1 (gender): {match.group(1)}")
print(f"Group 2 (school): {match.group(2)}")
print(f"Group 3 (last_name): {match.group(3)}")
else:
print("❌ NO MATCH")
# Let's try a more specific pattern
print("\nTrying more specific pattern...")
pattern2 = r'^(Female|Male)([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*\s+(?:High|School|Academy|Middle|Elementary))\s*([A-Z][a-z]+)$'
match2 = re.match(pattern2, test_text)
if match2:
print("✅ MATCH with specific pattern!")
print(f"Groups: {match2.groups()}")
else:
print("❌ NO MATCH with specific pattern")
# Let's see what happens if we split on space
parts = test_text.split()
print(f"\nSplit on space: {parts}")
# Let's try to manually parse it
if test_text.startswith(('Female', 'Male')):
gender = 'Female' if test_text.startswith('Female') else 'Male'
remaining = test_text[len(gender):]
print(f"Gender: {gender}")
print(f"Remaining: {remaining}")
# Look for school keywords
school_keywords = ['High', 'School', 'Academy', 'Middle', 'Elementary']
for keyword in school_keywords:
if keyword in remaining:
keyword_pos = remaining.find(keyword) + len(keyword)
school = remaining[:keyword_pos]
last_name = remaining[keyword_pos:]
print(f"School: {school}")
print(f"Last name: {last_name}")
break