run_referential_core_019.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 1 run_referential_core_019.py Source: /Voynich/run_referential_core_019.py SHA-256: cf984ab16615f05acc9b80a42c6098b02e37132684ed93ef8b08bbc3813fbdfa !/usr/bin/env python3 """REFERENTIAL-CORE-019: duplicate-illustration recurrence in the 75-stem core. Frozen gate: - Remove EXTERNAL-ANCHOR-ATTACK-018 label/register candidates A3 C1 and Q1 A3 B2. - Use the remaining 75 fixed proto-stems without remapping. - Duplicate groups come only from pre-existing ZL3b 'Same plant as' annotations. - ZL and GC are independent witnesses. - Compare count-IDF weighted page similarity to section-pair and opportunity matched random pairs (10,000 aggregate replicates). - Aggregate pass requires p<.05 in both witnesses and every duplicate pair above its matched-control median. - Stem promotion requires cross-witness support in >=2 duplicate groups and a selection-aware maximum-stat p<.05 in both witnesses. - Because every reusable duplicate group includes a question-marked source annotation, even a pass can establish only same-object recurrence, never a botanical species name or literal historical-language word. """ from __future__ import annotations import csv,hashlib,json,math,re from collections import Counter,defaultdict from pathlib import Path import numpy as np DATA=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') OUT=Path('referential_core_019');OUT.mkdir(exist_ok=True) SEED=20260829;REPS=10000;REMOVED={'A3 C1','Q1 A3 B2'} TOK_RE=re.compile(r'[A-Z][0-9a-z]');LOC_RE=re.compile(r'^<([^>.]+)\.([^,>]+),([^>]*)>\s*(.*)$') 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(text): text=re.sub(r'<[^>]*>','',text).replace('[','').replace(']','').replace(':','') out=[] for w in re.split(r'[.,\s]+',text): a=TOK_RE.findall(w) if len(a)>=3:out.append(' '.join(a[1:-1])) return out def parse(path,wit,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 pages=defaultdict(Counter);registers=defaultdict(lambda:defaultdict(Counter));allbodies=defaultdict(Cou nter) for fol,line,tag,text in rows: if not re.match(r'^f\d+[rv]\d?$',fol):continue reg='LABEL' if 'L' in tag else 'PROSE' if 'P' in tag else 'OTHER' for b in clean(text): allbodies[fol][b]+=1 if b in stems:pages[fol][b]+=1;registers[fol][reg][b]+=1 return pages,registers,allbodies def metadata_groups(path): cur='';items=[]