import json, re, os base = os.path.dirname(os.path.abspath(__file__)) art = open(os.path.join(base, "article.md"), encoding="utf-8").read() meta = json.load(open(os.path.join(base, "metadata.json"), encoding="utf-8")) def wc(text): return len(re.findall(r"[A-Za-z0-9][A-Za-z0-9.'’\-]*", text)) lines = art.splitlines() h1 = [l for l in lines if l.startswith("# ")][0][2:].strip() body_no_h1 = "\n".join(l for l in lines if not l.startswith("# ")) body_no_heads = "\n".join(l for l in lines if not l.startswith("#")) cite_re = re.compile(r"\((S\d-[a-z\-]+\.md), \"([^\"]+)\"\)") no_cites = cite_re.sub("", art) no_cites_no_heads = cite_re.sub("", body_no_heads) print("WORD COUNTS (article.md)") print(" whole file incl. H1, subheads, citations:", wc(art)) print(" excluding H1:", wc(body_no_h1)) print(" excluding all headings:", wc(body_no_heads)) print(" whole file excluding inline citations:", wc(no_cites)) print(" excluding headings and inline citations:", wc(no_cites_no_heads)) print(" whitespace-split whole file:", len(art.split())) print(" whitespace-split, no headings, no citations:", len(no_cites_no_heads.split())) print("METADATA") print(" keys:", sorted(meta.keys())) print(" headline chars:", len(meta["headline"]), "(need 50-70)") print(" headline matches article H1:", meta["headline"] == h1) print(" excerpt words:", len(meta["excerpt"].split()), "(need <=45)") print(" search_description chars:", len(meta["search_description"]), "(need 140-160)") print("CITATIONS") headings = {} inp = os.path.join(base, "..", "inputs") for fn in os.listdir(inp): txt = open(os.path.join(inp, fn), encoding="utf-8").read() headings[fn] = [l[3:].strip() for l in txt.splitlines() if l.startswith("## ")] ok = True cites = cite_re.findall(art) for fn, sec in cites: good = fn in headings and sec in headings[fn] ok = ok and good if not good: print(" BAD CITATION:", fn, sec) print(" inline citations:", len(cites), "| all resolve to a real file + section heading:", ok) print(" files cited:", sorted(set(f for f, _ in cites))) print("EXCLUDED-CLAIM SCAN (article + metadata; expect none)") blob = (art + " " + json.dumps(meta)).lower() for term in ["gdpr", "offline", "60%", "60 percent", "hallucinat", "fired", "paperwork department", "certified", "we tested", "i tested", "in my testing", "in our testing", "hands-on", "annual plan", "free trial", "s5-internal"]: print(" %-22s %s" % (term, "FOUND" if term in blob else "absent")) print(" 'USD 19' occurrences:", blob.count("usd 19"), "(expected 1, in the correction paragraph only)") print(" 'USD 29' occurrences:", blob.count("usd 29")) print("ARITHMETIC") print(" 3 seats x 29 =", 3 * 29, "| + OCR 12 =", 3 * 29 + 12) print(" vendor draft-time change: 50 -> 20 min =", 50 - 20, "min,", round((50 - 20) / 50 * 100), "% of median draft time (kept out of article)")