turkic-ocr-code / scripts /r5_freeze /make_endpoints.py
treoa's picture
Release 1
24aaa76
Raw History Blame Contribute Delete
2.17 kB
"""R5 FREEZE: endpoints.json for the scorer = EVALCODE's endpoints_proposal.json with three settings filled (freeze plan part B step 7):
T2.audited_languages = the language-scripts of PRINT's audit with at least 49 of 50 test lines matching, label 'checked by machine viewing';
reader_only_counts_as_pipeline = true (clarification H6 of amendment 3.3);
confirmed = true.
Nothing else is changed. usage: python -I make_endpoints.py PROPOSAL_JSON PRINT_AUDIT_JSON OUT_JSON
"""
import json
import sys
import time
prop_p, audit_p, out_p = sys.argv[1:4]
e = json.load(open(prop_p, encoding="utf-8"))
au = json.load(open(audit_p, encoding="utf-8"))
now = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
langs, detail = [], {}
for lang, v in sorted(au["languages"].items()):
fin = v["final"]
ok = bool(fin.get("audited")) and fin["matches"] >= 49 and fin["sample_size"] == 50
detail[lang] = "%d/%d%s" % (fin["matches"], fin["sample_size"], "" if ok else " (not audited)")
if ok:
langs.append(lang)
e["T2"]["audited_languages"] = langs
e["T2"]["audited_languages_label"] = "checked by machine viewing (the PRINT stage compared 50 test crops per language-script with their labels), not by a human"
e["T2"]["audited_languages_source"] = "records/R5/PRINT/audit.json key languages.<lang>.final (threshold: at least 49 of 50 exact): " + ", ".join("%s %s" % kv for kv in detail.items())
e["reader_only_counts_as_pipeline"] = True
e["reader_only_counts_as_pipeline_source"] = "clarification H6 of amendment 3.3 (records/R5/RULE/j11_v3_3_clarifications_2.txt): if no full pipeline memory is measured, gate G uses reader peak memory plus the detector chosen on validation; if the detector figure is missing, the reader figure alone is used and labelled 'reader only; detector not added'"
e["confirmed"] = True
e["confirmed_by"] = "stage FREEZE (freeze plan part B step 7)"
e["confirmed_utc"] = now
e["status"] = "CONFIRMED %s before any arm trained on mix_v1 (audited languages fixed before training, version 3); proposal by EVALCODE" % now
json.dump(e, open(out_p, "w", encoding="utf-8"), indent=2, ensure_ascii=False)
print("audited", langs, detail)