import sys, json
sys.path.insert(0, ".")
from pathlib import Path
import smart_extractor as se
from _lines import separator_barriers
D = Path("output/AndhraJyothi_Siddipet District_20260602_20260603_144919/pages")
png = D / "page_001.png"
regs0 = json.loads((D / "page_001.regions.json").read_text())["regions"]
regs = se.drop_masthead_regions(regs0, "andhra_jyothi", 1, png)
ds = se.find_article_starts_by_dateline(regs, str(png), "andhra_jyothi")
bars = separator_barriers(str(png), regs)
bl = se.cluster_all_article_blocks(regs, dateline_starts=ds, sep_lines=bars)
allmem = set()
for b in sorted(bl, key=lambda b: (b["bbox"][1], b["bbox"][0])):
    allmem |= set(b["members"])
    print(f"  {b['kind']:>1} anchor={b['anchor_id']:>3} bbox={b['bbox']} members={sorted(b['members'])}")
present = {r["id"] for r in regs if r.get("type") not in ("header","number")}
print("MISSING (not in any block):", sorted(present - allmem))
