run_external_anchor_attack_018.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 1 run_external_anchor_attack_018.py Source: /Voynich/run_external_anchor_attack_018.py SHA-256: 757b3a0a3e661f44637fac1167306970aba258dc9b402545dfda8f5ae3675450 !/usr/bin/env python3 """EXTERNAL-ANCHOR-ATTACK-018: blinded label/prose ranking then referent reveal. Frozen before reveal: - Universe: the previously fixed 77 productive stems. - Primary witnesses: ZL3b and GC2a/v101, independently. - Candidate gate per witness: >=2 exact label tokens, >=2 label folios, >=10 prose tokens, positive register-enrichment z, and familywise p < .05. - Cross-witness gate: both witnesses pass and label-folio Jaccard >= .50. - Reveal gate for 1:1 promotion: the same independently supplied, specific referent on >=2 distinct label folios. Broad section/domain is insufficient. - 1,000 nulls shuffle label/prose status within folio and witness; the maximum z over all 77 stems supplies the selection-aware familywise p-value. """ from __future__ import annotations import csv, hashlib, json, math, re from collections import Counter, defaultdict from pathlib import Path import fitz import numpy as np from PIL import Image, ImageDraw, ImageFont ROOT=Path('crosswalk002_inputs/Voynich_Line_Local_Reproducibility_2026-08-22/data') LEX=Path('proto_stem_lexicon_003/proto_stem_lexicon.csv') META=Path('external_voynich_units/data/voynich-units/ZL3b.txt') PDF=Path('library_scan/Voynich_Manuscript.pdf') OUT=Path('external_anchor_attack_018'); OUT.mkdir(exist_ok=True) SEED=20260829; REPS=1000 MISSING={12,*range(59,65),74,91,92,97,98,109,110} TOK_RE=re.compile(r'[A-Z][0-9a-z]') LOC_RE=re.compile(r'^<([^>.]+)\.([^,>]+),([^>]*)>\s*(.*)$') L={'A2':'ENTRY','C2':'ENTRY','Q2':'ENTRY','A1':'REFERENCE','A3':'REFERENCE','B2':'DOMAIN_SELECTOR','U2': 'DOMAIN_SELECTOR','D1':'CONTEXT','K1':'CONTEXT','L1':'CONTEXT','Q1':'CONTEXT'} R={'B1':'CLOSURE','B3':'CLOSURE','A1':'HANDOFF','C1':'HANDOFF','C2':'HANDOFF','F1':'HANDOFF','F3':'HANDO FF','A2':'TERMINAL','B2':'TERMINAL'} def section(f): n=int(re.search(r'\d+',f).group()) return 'Herbal' if n<=66 else 'Astro' if n<=73 else 'Bio' if 75<=n<=84 else 'Pharma' if 87<=n<=102 else 'Recipes' if 103<=n<=116 else 'Other' def clean_tokens(text): clean=re.sub(r'<[^>]*>','',text).replace('[','').replace(']','').replace(':','') out=[] for i,w in enumerate(re.split(r'[.,\s]+',clean)): a=TOK_RE.findall(w) if len(a)>=3: out.append((i,a,' '.join(a[1:-1]))) return out def parse_sta(path,witness,stems): rows=[]; pending=None for raw in path.read_text(errors='ignore').splitlines(): m=LOC_RE.match(raw) if m: fol,line,tag,text=m.groups(); pending=[fol,line,tag,text] if text.strip(): rows.append(tuple(pending)); pending=None elif pending and raw and not raw.startswith(('<','#')): pending[3]=(pending[3]+' '+raw).strip(); rows.append(tuple(pending)); pending=None events=[] for fol,line,tag,text in rows: