Enhance image text comparison functionality with detailed logging

- Added logging for OCR results and text matching outcomes in compare_image_text function.
- Updated JSON examples to support multiple expected results and improved structure for evaluator functions.
- Enhanced handling of expected text rules to include multiple variations for better matching accuracy.
This commit is contained in:
yuanmengqi
2025-07-10 22:32:53 +00:00
parent 4e3446d6fe
commit 6897e5320d
4 changed files with 161 additions and 18 deletions

View File

@@ -402,12 +402,17 @@ def check_direct_json_object(result, rules) -> float:
expected_value_list = expected_json.get(key)
logger.info(f"[DEBUG] Checking list key '{key}': expected_list={expected_value_list}, actual='{result.get(key)}'")
for each_expected_value in expected_value_list:
# Handle both list and string cases
if isinstance(result.get(key), list) and each_expected_value in result.get(key):
flag = 1
logger.info(f"[DEBUG] Found expected value '{each_expected_value}' in result list for key '{key}'")
break
elif isinstance(result.get(key), str) and each_expected_value == result.get(key):
flag = 1
logger.info(f"[DEBUG] Found expected value '{each_expected_value}' matches result string for key '{key}'")
break
if flag == 0:
logger.info(f"[DEBUG] No expected values found in result list for key '{key}', returning 0.0")
logger.info(f"[DEBUG] No expected values found in result for key '{key}', returning 0.0")
return 0.
elif isinstance(expected_json.get(key), str):
expected_str = expected_json.get(key)