Voynich Complete Reproducibility Compendium - 2026-08-28 Page 1804 top50 = sum(c for _, c in freq.most_common(50)) / n return dict(tokens=n, types=types, hapax_share=hapax / types, top50_coverage=top50) if __name__ == "__main__": rng = random.Random(20260818) by_lang = voynich_lines_by_language() vy_A, vy_B = by_lang["A"], by_lang["B"] n_A = sum(len(ln) for ln in vy_A) results = {} corpora = {} for name, path in (("bencao", SCRATCH / "zh_bencao.txt"), ("sanguo", SCRATCH / "zh_sanguo.txt")): for tonal in (True, False): key = f"{name}_{'tonal' if tonal else 'toneless'}" corpora[key] = chinese_syllable_lines(path, tonal) print("=== T1: syllable/token order information (share of H1) ===", flush=True) rows = {} for key, lines in corpora.items(): ml = match_tokens(lines, n_A) oi = order_info(ml, {}) rows[key] = oi["share"] print(f" {key:18s} {oi['share']*100:6.2f}%", flush=True) for key, lines in (("voynich_A", vy_A), ("voynich_B", vy_B)): oi = order_info(lines, {}) rows[key] = oi["share"] print(f" {key:18s} {oi['share']*100:6.2f}%", flush=True) results["order_info"] = rows print("=== T2: vocabulary structure at matched token counts ===", flush=True) rows = {} for key, lines in list(corpora.items()) + [("voynich_A", vy_A), ("voynich_B", vy_B)]: ml = match_tokens(lines, n_A) if key in corpora else lines vs = vocab_stats(ml) rows[key] = vs print(f" {key:18s} tokens={vs['tokens']:6d} types={vs['types']:5d} " f"hapax={vs['hapax_share']*100:4.1f}% " f"top50cov={vs['top50_coverage']*100:4.1f}%", flush=True) results["vocab"] = rows print("=== T3: pinyin letter-stream profile vs Voynich glyphs ===", flush=True) rows = {} pin = match_tokens(corpora["bencao_toneless"], 173076 // 4) pin = truncate(pin, 173076) for k in (0, 64): seg = bpe_checkpoints(pin, {k}, k)[k] st = stream_stats(pin, seg) rows[f"pinyin_k{k}"] = st print(f" pinyin k={k:3d}: types={st['types']:5d} H1={st['H1']:.2f} " f"H2={st['H2']:.2f} gap={st['gap']:.2f}", flush=True) print(" (voynich k=0: gap 1.60; k=64: gap 1.05 - from v5 E1)", flush=True) results["letter_profile"] = rows print("=== T4: substitution attack with pinyin LM (letter level) ===", flush=True) pin_letters = "".join(w for ln in corpora["bencao_toneless"] for w in ln) cut = int(len(pin_letters) * 0.85) lm = TrigramLM(pin_letters[:cut]) anchor = lm.anchor_bits(pin_letters[cut:]) rows = {} for name, lines in (("voynich_A", vy_A), ("voynich_B", vy_B), ("ngram_ctl_A", ngram_generate(vy_A)), ("ngram_ctl_B", ngram_generate(vy_B))): segmap, ustream, maps = pipeline_classes(lines, 64, [23]) r = match_index(ustream, maps[23], 23, lm, anchor, restarts=8) rows[name] = dict(index=r["index"], test_bits=r["test_bits"], scrambled_bits=r["scrambled_bits"], anchor_bits=anchor) print(f" {name:12s} index={r['index']:.3f} bits={r['test_bits']:.3f} " f"scr={r['scrambled_bits']:.3f} anchor={anchor:.3f}", flush=True) results["pinyin_attack"] = rows (OUT / "syllabic_results.json").write_text( json.dumps(results, indent=1, default=float)) print("done")