Voynich Master Archive - Volume 03 - Pages 2001-3000
Chinese classical control text, plus later workspace supplement files in the same PDF
PDF page 644 of 1000. Catalog page range 2001-3000.
Extracted text
Voynich Complete Reproducibility Compendium - 2026-08-28 Page 2643
# homophonic: each letter -> one of 3 groups (len 2), weighted choice
homo = {c: [make_groups([c], {c: 2})[c] for _ in range(3)] for c in letters}
def t_v2(c): return v2[c]
def t_v13(c): return v13[c]
def t_homo(c): return rng.choices(homo[c], weights=(0.6, 0.3, 0.1))[0]
return t_v2, t_v13, t_homo
# ------------------------------------------------------- self-citation gen
def selfcite_lines(vy_lines):
inventory = Counter(c for ln in vy_lines for w in ln for c in w)
glyphs, weights = zip(*inventory.items())
seed = [w for ln in vy_lines[:8] for w in ln]
hist = list(seed)
n_tokens = sum(len(ln) for ln in vy_lines)
line_lens = [len(ln) for ln in vy_lines]
out, cur = [], []
li = 0
while len(out) < len(line_lens) and li < n_tokens * 2:
li += 1
w = list(rng.choice(hist[-200:]))
for _ in range(rng.choices((0, 1, 2), weights=(0.25, 0.5, 0.25))[0]):
op = rng.choice(("sub", "ins", "del"))
i = rng.randrange(len(w)) if w else 0
if op == "sub" and w:
w[i] = rng.choices(glyphs, weights)[0]
elif op == "ins":
w.insert(i, rng.choices(glyphs, weights)[0])
elif op == "del" and len(w) > 1:
del w[i]
token = "".join(w)
if not token:
continue
hist.append(token); cur.append(token)
if len(cur) >= line_lens[len(out)]:
out.append(cur); cur = []
return out
# ------------------------------------------------------------------- BPE --
def truncate(lines, target_glyphs):
out, n = [], 0
for ln in lines:
out.append(ln)
n += sum(len(w) for w in ln)
if n >= target_glyphs:
break
return out
def bpe_checkpoints(lines, checkpoints, max_merges):
"""Run BPE on word types; yield (k, segmented word map) at checkpoints."""
wfreq = Counter(w for ln in lines for w in ln)
segs = {w: tuple(w) for w in wfreq}
results = {}
if 0 in checkpoints:
results[0] = dict(segs)
pair_count: Counter = Counter()
where: dict[tuple, set] = defaultdict(set)
for w, seg in segs.items():
for a, b in zip(seg, seg[1:]):
pair_count[(a, b)] += wfreq[w]
where[(a, b)].add(w)
for k in range(1, max_merges + 1):
if not pair_count:
break
(a, b), cnt = max(pair_count.items(), key=lambda x: (x[1], x[0]))
if cnt < 2:
break
new = a + b
for w in list(where[(a, b)]):
seg = segs[w]
f = wfreq[w]
# remove old pair counts for this word
for x, y in zip(seg, seg[1:]):
pair_count[(x, y)] -= f
if pair_count[(x, y)] <= 0:
del pair_count[(x, y)]
where[(x, y)].discard(w)
# apply merge
out = []
i = 0
while i < len(seg):
if i < len(seg) - 1 and seg[i] == a and seg[i+1] == b:
out.append(new); i += 2
else:
out.append(seg[i]); i += 1
seg = tuple(out)
segs[w] = seg
for x, y in zip(seg, seg[1:]):
pair_count[(x, y)] += f
where[(x, y)].add(w)
if k in checkpoints:
results[k] = dict(segs)
return results