| from __future__ import annotations |
|
|
| import argparse |
| import json |
| import re |
| from pathlib import Path |
|
|
|
|
| ENGLISH_MARKERS = re.compile(r"\b(okay|let|first|then|wait|problem|answer|step|correct|hmm)\b", re.IGNORECASE) |
|
|
|
|
| def parse_args() -> argparse.Namespace: |
| parser = argparse.ArgumentParser() |
| parser.add_argument("results_json") |
| return parser.parse_args() |
|
|
|
|
| def main() -> None: |
| args = parse_args() |
| rows = json.loads(Path(args.results_json).read_text()) |
| compliant = 0 |
| for row in rows: |
| output = row["output"] |
| match = re.search(r"<think>(.*?)</think>", output, re.DOTALL) |
| think = match.group(1).strip() if match else "" |
| lines = [line.strip() for line in think.splitlines() if line.strip()] |
| pseudocode_like = sum(1 for line in lines if "=" in line or "->" in line) |
| has_english = any(ENGLISH_MARKERS.search(line) for line in lines) |
| if lines and pseudocode_like >= max(3, int(len(lines) * 0.6)) and not has_english: |
| compliant += 1 |
|
|
| summary = { |
| "compliant": compliant, |
| "total": len(rows), |
| "compliance": round(compliant / len(rows), 4) if rows else 0.0, |
| } |
| print(json.dumps(summary, indent=2)) |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|