# decryption_complete: false # source: archive/local/external_voynich_units/voynich_decipherment_repro_bundle/decipherment_attack_v5/e4_catalog.py # stated_sha256: 83ff8d23617a54698be9da3b0ec3aeb8ba458789192db78a5d90c99f1a2c8c0c # matches_stated_sha256: false # pdf_pages: 304-305 # note: The stated SHA-256 is the digest printed in the PDF. # The PDF page extract follows the form feed. decryption_complete stays false. Voynich Complete Reproducibility Compendium - 2026-08-28 Page 2303 archive/local/external_voynich_units/voynich_decipherme nt_repro_bundle/decipherment_attack_v5/e4_catalog.py SHA-256: 83ff8d23617a54698be9da3b0ec3aeb8ba458789192db78a5d90c99f1a2c8c0c | 4,139 bytes | workspace supplement #!/usr/bin/env python3 """E4: Species Plantarum (Linnaeus) as a genuine catalogue/register control. - E3-style positional vs sequential MI (records = paragraphs). - E1-style BPE curve for the plain catalogue and a verbose-2 cipher of it. - Interior-only positional MI for Voynich (excludes the known line-edge effects; tests whether positional structure runs through the line). """ from __future__ import annotations import json, math, random, re, sys from collections import Counter from pathlib import Path SCRATCH = Path(__file__).resolve().parent sys.path.insert(0, str(SCRATCH)) from unit_probe import (voynich_lines, collapse, bpe_checkpoints, stream_stats, truncate, make_groups, cipher_corpus) from e3_positional import analyse, mi_pairs, posbin def species_records() -> list[list[str]]: txt = "" for f in ("species1.txt", "species2.txt"): t = (SCRATCH / "latin_controls" / f).read_text(encoding="utf-8", errors="replace") a = t.find("*** START"); b = t.find("*** END") t = t[t.find("\n", a)+1: b if b > 0 else len(t)] txt += "\n\n" + t txt = re.sub(r"\[[^\]]*\]", " ", txt) # transcriber notes txt = txt.lower().replace("\u00E6", "ae").replace("\u0153", "oe") txt = txt.replace("v", "u").replace("j", "i") recs = [] for para in re.split(r"\n\s*\n", txt): words = re.findall(r"[a-z]+", para) if 3 <= len(words) <= 40: recs.append(words) return recs def interior_positional(lines, n_shuffles=60): """Positional MI using only interior tokens (positions 1..n-2).""" freq = Counter(w for ln in lines for w in ln) keep = {t for t, _ in freq.most_common(2000)} sym = lambda w: w if w in keep else "" sls = [[sym(w) for w in ln] for ln in lines if len(ln) >= 5] def pairs(ls): return [(w, posbin(i, len(ln))) for ln in ls for i, w in enumerate(ln) if 0 < i < len(ln)-1] obs = mi_pairs(pairs(sls)) r = random.Random(9) flat = [w for ln in sls for w in ln] lens = [len(ln) for ln in sls] null = [] for _ in range(n_shuffles): f = flat[:]; r.shuffle(f) it = iter(f) s2 = [[next(it) for _ in range(L)] for L in lens] null.append(mi_pairs(pairs(s2))) ex = obs - sum(null)/len(null) H1 = mi_pairs([(w, w) for ln in sls for i, w in enumerate(ln) if 0 < i < len(ln)-1]) print(f"interior positional: excess={ex:.4f}b ({ex/H1*100:.2f}% of H1={H1:.2f})", flush=True) return dict(excess=ex, H1=H1, share=ex/H1) if __name__ == "__main__": out = {} recs = species_records() n_words = sum(len(r) for r in recs) print(f"species plantarum: {len(recs)} records, {n_words} words", flush=True) print("--- E3 on catalogue ---", flush=True) out["species_pos_seq"] = analyse("species", recs) print("--- interior positional ---", flush=True) vy = [[collapse(w) for w in ln] for ln in voynich_lines()] out["voynich_interior_pos"] = interior_positional(vy) out["species_interior_pos"] = interior_positional(recs) print("--- BPE curves: catalogue plain + verbose-2 ---", flush=True) freq = Counter(c for r in recs for w in r for c in w) letters = [c for c, _ in freq.most_common()] import random as _r v2 = make_groups(letters, {c: 2 for c in letters}) corp = {"species": recs, "species_verbose2": cipher_corpus(recs, lambda c: v2[c])} Voynich Complete Reproducibility Compendium - 2026-08-28 Page 2304 target = 173076 # match the voynich glyph count from E1 cps = [0, 16, 64, 256, 1024] out["bpe"] = {} for name, lines in corp.items(): lines = truncate(lines, target) res = bpe_checkpoints(lines, set(cps), max(cps)) out["bpe"][name] = {} for k, segmap in sorted(res.items()): st = stream_stats(lines, segmap) out["bpe"][name][k] = st print(f"{name:18s} k={k:5d} types={st['types']:5d} len={st['mean_len']:.2f} " f"H1={st['H1']:.3f} H2={st['H2']:.3f} gap={st['gap']:.3f}", flush=True) (SCRATCH / "output" / "e4_results.json").write_text(json.dumps(out, indent=2))