Voynich Master Archive - Volume 03 - Pages 2001-3000
Chinese classical control text, plus later workspace supplement files in the same PDF
PDF page 651 of 1000. Catalog page range 2001-3000.
Extracted text
Voynich Complete Reproducibility Compendium - 2026-08-28 Page 2650
archive/local/external_voynich_units/voynich_decipherme
nt_repro_bundle/decipherment_attack_v6/attack_voynich.
py
SHA-256: 3e6fac36a5c4e27fc6403d82cde309e178ff3a0a90f99d85eadc188aa81fa159 | 4,220 bytes | workspace supplement
#!/usr/bin/env python3
"""The substitution attack applied to Voynichese, per Currier dialect,
with an n-gram-generator negative control.
For each (stream, m, language): hill-climb classes->letters on even lines,
evaluate held-out per-symbol log-likelihood on odd lines, normalise into the
language-match index (0 = no sequential structure recovered beyond frequency
matching, 1 = as language-like as real held-out text of that language).
The negative control is a corpus sampled from an order-3 glyph model fitted
to each stream (same size, same token/line structure) and pushed through the
IDENTICAL pipeline: it bounds how much "language-likeness" the optimizer can
manufacture from small-scale glyph statistics alone.
"""
from __future__ import annotations
import json, random, sys
from collections import Counter, defaultdict
from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
from attack_lib import (build_lms, pipeline_classes, match_index,
voynich_lines_by_language, truncate)
OUT = HERE / "output"
OUT.mkdir(exist_ok=True)
LANGS = ["latin", "latin_novowels", "italian", "german", "french",
"english", "hebrew"]
M_MAIN = 23
M_SENS = [20, 26]
K = 64
def ngram_generate(lines, seed=7):
"""Order-3 char model (incl. token boundary '#') fitted to the stream;
sample a same-shape corpus. Generation is seeded from real contexts that
end at a token boundary; there is NO fallback to the original lines (a
silent fallback would make the negative control identical to the data)."""
rng = random.Random(seed)
big = "#" + "#".join(w for ln in lines for w in ln) + "#"
ctx = defaultdict(Counter)
for i in range(2, len(big)):
ctx[big[i - 2:i]][big[i]] += 1
starts = [big[i:i + 2] for i in range(1, len(big) - 2) if big[i + 1] == "#"]
out = []
for ln in lines:
target_tokens = len(ln)
s = rng.choice(starts)
tokens, cur = [], ""
guard = 0
while len(tokens) < target_tokens and guard < 20000:
guard += 1
dist = ctx.get(s[-2:])
if not dist:
s += rng.choice(starts)
cur = ""
continue
chars, weights = zip(*dist.items())
c = rng.choices(chars, weights=weights)[0]
s += c
if c == "#":
if cur:
tokens.append(cur)
cur = ""
else:
cur += c
out.append(tokens if tokens else ["qokedy"])
return out
def run_stream(name, lines, lms, m_list, langs, results, restarts=8):
print(f"=== {name}: {len(lines)} lines, "
f"{sum(len(w) for ln in lines for w in ln)} glyphs", flush=True)
segmap, ustream, maps = pipeline_classes(lines, K, m_list)
for m in m_list:
cm = maps[m]
for lang in langs if m == M_MAIN else ["latin", "hebrew"]:
lm, anchor = lms[lang]
r = match_index(ustream, cm, m, lm, anchor, restarts=restarts)
key = f"{name}|m{m}|{lang}"
results[key] = dict(index=r["index"], test_bits=r["test_bits"],
scrambled_bits=r["scrambled_bits"],