run_libro_voynich_direct_022.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 1 run_libro_voynich_direct_022.py Source: /Voynich/run_libro_voynich_direct_022.py SHA-256: e1b70c2bea9ec066d4f84e105faf2dc7c7ef885d5d19c3541391a4ec0ab494d6 !/usr/bin/env python3 """LIBRO-VOYNICH-DIRECT-022: frozen 50-sentence job-shape distribution control.""" import csv, hashlib, itertools, json, math, re from collections import Counter from pathlib import Path ROOT = Path(__file__).resolve().parent OUT = ROOT / "libro_voynich_direct_022" OUT.mkdir(exist_ok=True) TXT = ROOT / "tmp/pdfs/libro_direct/libro.txt" RAW = ROOT / "crosswalk002_inputs/Voynich_Line_Local_Reproducibility_2026-08-22/data" TAGS = ("MOVE", "SIGN", "MEASURE", "REPORT", "MARVEL", "ASSET") CROSSWALK = {"MOVE":"BIO", "SIGN":"LABEL", "MEASURE":"PHARMA", "REPORT":"RECIPES", "MARVEL":"ASTRO", "ASSET":"HERBAL"} def clean_page(x): lines=[] for s in x.splitlines(): s=re.sub(r"\s+", " ", s).strip() if not s or re.fullmatch(r"[\d ivxlcdm,.-]+", s.lower()): continue if re.search(r"C\.\s*R\.\s*M\.|See Plate|PLATE [IVXLCDM]", s, re.I): continue lines.append(s) return " ".join(lines) def tag_sentence(s): z=s.lower() if re.search(r"marvellous|marvelous|miracle|magical virtues|secrets of the stars",z): return "MARVEL" if re.search(r"\b(device|flag|ensign|arms|coat of arms|for his sign)\b",z): return "SIGN" if re.search(r"\b\d+\s+(miles?|leagues?|days? journey|days?)\b|distance is|journey in length|journey in width",z): return "MEASURE" if re.search(r"\b(i departed|i left|i went|i returned|i entered|i arrived|i crossed|i travelled|on leaving|afterwards i departed)\b",z): return "MOVE" if re.search(r"\b(they say|they told me|i was told|know that|it is said|they call|i heard|i enquired)\b",z): return "REPORT" return "ASSET" pages=TXT.read_text(errors="ignore").split("\f") candidates=[] for pageno in range(23, min(117,len(pages))): text=clean_page(pages[pageno]) for j,s in enumerate(re.split(r"(?<=[.!?])\s+(?=[A-Z])",text)): s=s.strip() wc=len(re.findall(r"\b\w+\b",s)) if 7 <= wc <= 90 and not re.search(r"Hakluyt|Jimenez|Espada|Markham|Franciscan shows|according to",s,re.I): candidates.append({"page_index":pageno,"sentence_index":j,"sentence":s,"tag":tag_sentence(s) }) Two required hinge receipts, selected by exact content before systematic sampling. anchors=[] for needle in ("From the time I came to MALSA", "castle of MAGOT because"): hits=[r for r in candidates if needle.lower() in r["sentence"].lower()] if not hits: raise RuntimeError("Required anchor not found: "+needle) anchors.append(hits[0]) pool=[r for r in candidates if r not in anchors] Systematic corpus-wide sample of 48, with a hash-derived offset fixed by test id. step=len(pool)/48 offset=(int(hashlib.sha256(b"LIBRO-VOYNICH-DIRECT-022").hexdigest()[:8],16)%10000)/10000*step chosen=[]; used=set()