File size: 491 Bytes
ed46c5d
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
"""cutpreds.py <in.jsonl> <out.jsonl>: apply loopcut.cut_loops to recognizer outputs, keeping the raw output
in pred_raw (the same transformation that produced preds/ocr_*_ocr4b_mixcut.jsonl)."""
import json
import sys

from loopcut import cut_loops

with open(sys.argv[2], "w") as f:
    for l in open(sys.argv[1]):
        r = json.loads(l)
        raw = r.get("pred_raw", r["pred"])
        f.write(json.dumps(dict(r, pred=cut_loops(raw or ""), pred_raw=raw), ensure_ascii=False) + "\n")