CheneyWong's picture
canonical OTSL ground truth: scripts/README.md
f57dfbb verified
|
Raw History Blame Contribute Delete
2.37 kB

scripts/

otsl_norm.py — the canonicaliser

HTML → PaddleOCR-VL 1.6's own OTSL convention. This is what produced the otsl column of the shards.

import sys; sys.path.insert(0, ".")
from otsl_norm import html_to_otsl

otsl = html_to_otsl(html)          # canonical OTSL

Rules it implements (they mirror paddlex/inference/pipelines/paddleocr_vl/uilts.py::otsl_parse_texts, the parser PaddleOCR-VL 1.6 uses at inference time):

  • cell origin → <fcel> + text, or <ecel> when the cell is empty;
  • colspan → <lcel> in the same row, to the right;
  • rowspan → <ucel> in the row(s) below, in the same column;
  • merged both ways → <xcel>;
  • rows are not padded — a row lists the cells it actually has;
  • cell text: leading/trailing whitespace stripped, internal whitespace runs collapsed to a single space.

Self-check (parses its own output back with the official parser and compares cell by cell):

python3 validate_otsl_norm.py <pack_dir> 3000   # -> 99.77% identical

canonical_teds.py — the scorer

The table scorer used for the reference runs. Primary metric is TEDS-S; text_profile="canonical" (the default) flattens tags, decodes entities, converts LaTeX to Unicode and collapses whitespace on both sides.

Note: for pure-structure tables (every cell empty, e.g. sprint_mustard) TEDS is undefined and only TEDS-S is meaningful.

build_norm_pack.py — rebuild the ground truth of a pack

python3 build_norm_pack.py --src <old_pack> --out <new_pack> --workers 8

Rebuilds the otsl column from the html column. It keeps the source OTSL instead whenever the HTML in that pack is only a shell (all cells empty, the text living in the source annotation) — otherwise the text would be lost. Set POVL_ env vars are not needed here; the rule is hard-coded and logged per shard.

compare_runs.py — paired comparison of two runs

python3 compare_runs.py --a <run_tag> --b <run_tag> --out report.json

Pairs the two runs by sample id and reports per-cohort deltas with a paired bootstrap CI. Use the 合计(配对同 id, n=…) line for the headline number; the 合计(按样本) line compares A's own sample set against B's own sample set, which mixes two different populations when the two runs were scored on different subsets.