import json, sys need={"id","summary","sequence","attempted","gaps","v1_label_supported","rationale","flags","contradictions","off_case_links","record_only","facts","notes_for_sofia"} b=json.load(open(sys.argv[1],encoding='utf-8')); bad=0 import re, os nn=re.search(r'batch-(\d+)',sys.argv[1]).group(1) lists=json.load(open(os.path.join(os.path.dirname(sys.argv[1]),'batch-lists.json'))) expected=lists.get(nn) if expected is not None and sorted(c['id'] for c in b)!=sorted(expected): print("ID MISMATCH: expected",sorted(expected),"got",sorted(c['id'] for c in b)); bad+=1 print("cases:",len(b),"ids:",[c['id'] for c in b]) for c in b: miss=need-set(c); cats=c['summary'].count('**')//2 vio=[l for l in c['summary'].split('\n') if l.startswith('**Violence Used')] ok=bool(vio) and ('Detention' in vio[0] or 'No detention' in vio[0]) if miss or cats<6 or len(c['flags'])!=6 or not ok: bad+=1 print(f" {c['id']}: missing={sorted(miss) or '-'} cats={cats} flags={len(c['flags'])} det={'ok' if ok else 'MISSING'} seq={c['sequence']} v1ok={c.get('v1_label_supported')}") print("STRUCTURE", "OK" if not bad else f"PROBLEMS in {bad}")