File size: 2,999 Bytes
fa8b928
34a0aee
 
 
 
 
 
 
 
c949561
 
 
34a0aee
 
 
 
 
 
 
 
 
fa8b928
 
 
34a0aee
 
 
 
fa8b928
 
 
34a0aee
 
 
 
fa8b928
 
34a0aee
fa8b928
 
 
34a0aee
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
"""KoOCR-Bench v1 weighted total from koocr_score.py outputs.
Usage: koocr_total.py [--bbox-override JSON] [--drop eng,eng] [--no-handwriting] SCORES.txt [SCORES2.txt ...]
- Engines with several runs (name_r1, name_r2) are averaged as 'name'.
- --bbox-override: {"engine": {"slice": rate}} for engines whose boxes come in a separate layout list (e.g. PaddleOCR-VL).
- A component an engine has no value for is dropped for that engine and its weights renormalised (marked in the table).
Higher is better everywhere: text slices use 1 - CER (CER = normalised edit distance + 2 x foreign-script chars not in
the truth, capped at 1 per page), table slices use TEDS on HTML tables only."""
import json, re, sys, collections
# v1.1 (2026-10-05): kostat .15->.18, tables .10->.12, order .08->.05, grid .03->.02; totals divide by the weight sum
W = {"gwanbo": .15, "kostat": .18, "kdi": .12, "tables": .12, "handwriting": .10, "user": .10,
     "bbox": .08, "order": .05, "suneung": .05, "heading": .04, "grid": .02}
a = sys.argv[1:]; ov = {}; drop = set()
while a and a[0].startswith("--"):
    o = a.pop(0)
    if o == "--bbox-override": ov = json.load(open(a.pop(0)))
    elif o == "--drop": drop = set(a.pop(0).split(","))
    elif o == "--no-handwriting": W.pop("handwriting")
TXT = {"gwanbo_table": "gwanbo", "kdi_headings": "kdi", "suneung2026": "suneung", "user_real": "user", "handwritten": "handwriting"}
v = collections.defaultdict(lambda: collections.defaultdict(list))
for f in a:
    for l in open(f):
        m = re.match(r"(\S+)\s+(\S+)\s+n=\s*(\d+)\s+missing=\d+\s+(.*)", l)
        if not m: continue
        sl, eng, n = m[1], re.sub(r"_r\d+$", "", m[2]), int(m[3])
        if eng in drop: continue
        rest = dict(zip(*[iter(m[4].split())] * 2)); g = lambda k: float(rest[k])
        if "cer" in rest and TXT[sl] in W: v[eng][TXT[sl]].append((1 - g("cer"), n))
        if "teds" in rest:
            v[eng]["kostat" if sl == "kostat_wide" else "tables"].append((g("teds"), n)); v[eng]["grid"].append((g("grid_exact"), n))
        if "heading_recall" in rest: v[eng]["heading"].append((g("heading_recall"), n))
        if "order" in rest: v[eng]["order"].append((g("order"), n))
        if sl == "handwritten" and "handwriting" not in W: continue
        if "bbox" in rest: v[eng]["bbox"].append((ov.get(eng, {}).get(sl, g("bbox")), n))
avg = lambda xs: sum(x * n for x, n in xs) / sum(n for x, n in xs)
rows = []
for eng, c in v.items():
    comp = {k: avg(x) for k, x in c.items() if k in W}
    ks = [k for k in W if k in comp]
    rows.append((sum(W[k] * comp[k] for k in ks) / sum(W[k] for k in ks), eng, comp, [k for k in W if k not in comp]))
rows.sort(reverse=True)
print("| rank | engine | total | " + " | ".join(W) + " |")
print("|---|---|---|" + "---|" * len(W))
for i, (t, eng, comp, miss) in enumerate(rows, 1):
    print(f"| {i} | {eng}{' *' if miss else ''} | {t:.4f} | " + " | ".join(f"{comp[k]:.3f}" if k in comp else "–" for k in W) + " |")