(result: dict[str, Any])
| 437 | |
| 438 | |
| 439 | def normalize_result(result: dict[str, Any]) -> dict[str, Any]: |
| 440 | normalized = dict(result) |
| 441 | normalized['should_apply_label'] = as_bool(normalized.get('should_apply_label')) |
| 442 | |
| 443 | confidence = str(normalized.get('confidence') or 'low').strip().lower() |
| 444 | if confidence not in {'high', 'medium', 'low'}: |
| 445 | confidence = 'low' |
| 446 | normalized['confidence'] = confidence |
| 447 | |
| 448 | normalized['summary'] = str(normalized.get('summary') or '').strip() |
| 449 | normalized['criteria_met'] = normalize_string_list(normalized.get('criteria_met')) |
| 450 | normalized['disqualifiers'] = normalize_string_list(normalized.get('disqualifiers')) |
| 451 | |
| 452 | if confidence != 'high': |
| 453 | normalized['should_apply_label'] = False |
| 454 | if normalized['disqualifiers']: |
| 455 | normalized['should_apply_label'] = False |
| 456 | |
| 457 | return normalized |
| 458 | |
| 459 | |
| 460 | def main() -> int: |
no test coverage detected