Voynich Master Archive - Volume 07 - Pages 6001-7000
Test CSV, JSON, and Markdown records. Sections carry a Source path and a SHA-256 line.
PDF page 154 of 1000. Catalog page range 6001-7000.
Extracted text
run_libro_voynich_direct_022.py
VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 2
for i in range(48):
idx=min(len(pool)-1,int(offset+i*step))
while idx in used and idx+1<len(pool): idx+=1
used.add(idx); chosen.append(pool[idx])
sample=sorted(chosen+anchors,key=lambda r:(r["page_index"],r["sentence_index"]))
for i,r in enumerate(sample,1): r["sample_id"]=f"LIB-{i:03d}"; r["forced_anchor"]=int(r in anchors)
with (OUT/"libro_50_sentence_tag_ledger.csv").open("w",newline="") as f:
w=csv.DictWriter(f,fieldnames=["sample_id","page_index","sentence_index","forced_anchor","tag","sent
ence"])
w.writeheader();w.writerows(sample)
def vsection(folio):
n=int(re.search(r"\d+",folio).group())
if n<=66:return "HERBAL"
if n<=73:return "ASTRO"
if 75<=n<=84:return "BIO"
if 87<=n<=102:return "PHARMA"
if 103<=n<=116:return "RECIPES"
return "OTHER"
def parse_witness(path):
counts=Counter(); rows=[]; folio=None
for line in path.read_text(errors="ignore").splitlines():
m=re.match(r"^<(f\d+[rv])>",line)
if m: folio=m.group(1); continue
m=re.match(r"^<(f\d+[rv])\.([^,>]+),([^;>]+)",line)
if not m: continue
fol=m.group(1); locus=m.group(3); sec=vsection(fol)
if "L" in locus: typ="LABEL"
elif sec in ("HERBAL","ASTRO","BIO","PHARMA","RECIPES"): typ=sec
else: continue
counts[typ]+=1; rows.append({"folio":fol,"locus":locus,"type":typ})
return counts,rows
def js_div(p,q):
m=[(a+b)/2 for a,b in zip(p,q)]
def kl(a,b): return sum(x*math.log2(x/y) for x,y in zip(a,b) if x>0 and y>0)
return .5*kl(p,m)+.5*kl(q,m)
lib_counts=Counter(r["tag"] for r in sample)
results=[]; witness_ledgers={}
for wit,fn in (("ZL","ZL.txt"),("GC","GC.txt")):
vc,rows=parse_witness(RAW/fn); witness_ledgers[wit]=rows
lp=[lib_counts[t]/50 for t in TAGS]
total=sum(vc.values()); vp=[vc[CROSSWALK[t]]/total for t in TAGS]
obs=js_div(lp,vp)
null=[]
types=[CROSSWALK[t] for t in TAGS]
for perm in itertools.permutations(types):
null.append(js_div(lp,[vc[x]/total for x in perm]))
p=(1+sum(x<=obs for x in null))/(1+len(null))
results.append({"witness":wit,"libro_n":50,"voynich_loci":total,"js_divergence":obs,
"permutation_p_low_similarity":p,"crosswalk":json.dumps(CROSSWALK,sort_keys=True),
**{"libro_"+t:lib_counts[t] for t in TAGS},
**{"voynich_"+x:vc[x] for x in types}})
with (OUT/"cross_corpus_distribution_results.csv").open("w",newline="") as f:
w=csv.DictWriter(f,fieldnames=results[0]);w.writeheader();w.writerows(results)
for wit,rows in witness_ledgers.items():
with (OUT/f"voynich_{wit.lower()}_locus_ledger.csv").open("w",newline="") as f:
w=csv.DictWriter(f,fieldnames=rows[0]);w.writeheader();w.writerows(rows)
same_direction=all(r["permutation_p_low_similarity"]<.05 for r in results)
coverage_ok=all(lib_counts[t]>0 for t in TAGS)
Sampling sensitivity: 200 independently offset systematic 48+2-anchor samples.