measure_pharma_024.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 3 def main(): x=pd.read_csv(IN); x['section']=x.folio.map(section) feats=[] for keys,g in x.groupby(['witness','folio','line','section'],sort=False): z=line_features(g); z.update(dict(zip(['witness','folio','line','section'],keys))); feats.append(z) d=pd.DataFrame(feats); d.to_csv(OUT/'line_features.csv',index=False) allr=[];allw=[];allp=[];summ=[] for w in ['ZL','GC']: r,ww,p,s=analyze(d,w);allr.append(r);allw.append(ww);allp.append(p);summ.append(s) pd.concat(allr).to_csv(OUT/'fold_models.csv',index=False); pd.concat(allw).to_csv(OUT/'contrasts.csv', index=False); pd.concat(allp).to_csv(OUT/'predictions.csv',index=False) summary={'test':'MEASURE-PHARMA-024','seed':SEED,'frozen_gate':{'series_vs_base':'positive >=4/5 folds both witnesses','full_vs_repetition':'positive mean and permutation p<.05 both witnesses'},'results':summ} summary['pass']=all(s['observed_full_over_repetition_bits']>0 and s['permutation_p']<.05 for s in summ) (OUT/'summary.json').write_text(json.dumps(summary,indent=2)) c=pd.concat(allw); lines=['# MEASURE–PHARMA–024','', '## Outcome','',('**PASS**' if summary['pass'] else '**FAIL / NOT PROMOTED**'),'', 'This prospective test asked whether quantity-like structural series distinguish Pharma from same-range Herbal text after controlling ordinary repetition and line length. It did not assign meanings to glyphs or use illustrations.','', '## Results',''] for s in summ: q=c[c.witness==s['witness']]; lines += [f"### {s['witness']}",'',f"- Full over repetition: {s['observed_full_over_repetition_bits']:+.6f} bits/token-equivalent line log loss",f"- Conditional permutation p: {s['permutation_p']:.6f}",f"- Lines / folios: {s['n_lines']} / {s['n_folios']}",'',q.to_markdown(index=False,floatfmt='.6f'),''] lines += ['## Interpretation','', 'A pass would support a measurement-like structural layer, not a translation. A failure means the Libro MEASURE→Pharma page-level analogy has not generated a manuscript-level quantity signature. Ordinary repetition remains previously established structure and is not counted as new semantic evidence.','', '## Controls','', '- Primary contrast restricted to Herbal and Pharma; no diagrams or labels used.', '- ZL and GC analyzed independently.', '- Five folio-held-out folds.', '- Baseline controls line length and resolution.', '- Incremental gate charges ordinary repetition before testing variable-frame series.', '- 1,000 conditional permutations within held-out line-length bins.', '- No seventh recovery rule is added by this test.'] (OUT/'report.md').write_text('\n'.join(lines)) files=[p for p in OUT.iterdir() if p.is_file() and p.name!='SHA256SUMS.txt']; manifest='\n'.join(f"{hashlib.sha256(p.read_bytes()).hexdigest()} {p.name}" for p in sorted(files))+'\n'; (OUT/'SHA256SUMS.txt').write_text(manifest) print(json.dumps(summary,indent=2)) if __name__=='__main__':main()