import json
from pathlib import Path
import numpy as np
D = Path("output/AndhraJyothi_Siddipet District_20260602_20260603_144919/pages")
for pg in (1,2,3,4):
    regs = json.loads((D/f"page_{pg:03d}.regions.json").read_text())["regions"]
    texts=[r for r in regs if r.get("type")=="text"]
    ws=[r["bbox"][2]-r["bbox"][0] for r in texts]
    pitch=int(np.median(ws)) if ws else 0
    docs=[r for r in regs if r.get("type")=="doc_title"]
    print(f"== PAGE {pg}: textmedian(pitch)={pitch}, {len(docs)} doc_titles ==")
    for r in sorted(docs,key=lambda r:r["bbox"][1]):
        b=r["bbox"]; w=b[2]-b[0]
        print(f"   doc#{r['id']:>3} bbox={b} w={w} (~{w/max(1,pitch):.1f} col)")
