import json from math_sanitizer import sanitize_math_ocr_hotfix from orchestrator import select_best_anchor def verify_v111_hotfix(): print("๐Ÿš€ Starting BuddyMath V1.1.1 Hotfix Verification") # 1. Test Aggressive Sanitization (CTO Requirement) print("\n๐Ÿงผ Testing Aggressive Sanitization:") test_cases = [ (" frac(x)(2)", "((x)/(2))"), ("frac (x) ( 2 )", "((x)/(2))"), ("\\left( x + 1 \\right)", "(x+1)") ] for input_str, expected in test_cases: result = sanitize_math_ocr_hotfix(input_str) print(f" - '{input_str}' -> '{result}'") assert result == expected or result == expected.replace(" ", ""), f"Sanitization mismatch: {result} != {expected}" print(" โœ… Aggressive Sanitization - PASSED") # 2. Test Smart Anchor Selection print("\nโš“ Testing Smart Anchor Selection:") candidates = ["f(x)=x", "f(x)=x^2+1", "f(x)=x^2"] best = select_best_anchor(candidates) print(f" - Best of {candidates} -> '{best}'") assert best == "f(x)=x^2+1", "Smart anchor selection failed (longest policy)" print(" โœ… Smart Anchor Selection - PASSED") print("\n๐Ÿ† BuddyMath V1.1.1 Hotfix Verified!") if __name__ == "__main__": verify_v111_hotfix()