Voynich Complete Reproducibility Compendium - 2026-08-28 Page 1798 ap = argparse.ArgumentParser() ap.add_argument('zl', type=Path) ap.add_argument('--outdir', type=Path, required=True) args = ap.parse_args() args.outdir.mkdir(parents=True, exist_ok=True) pages = parse_zl(args.zl) herbal_pages = [p for p in pages.values() if p.paragraph_tokens] links = [] for source in pages.values(): for target_name, row, col, rawref in source.refs: target = pages.get(target_name) if target is None: continue cands, mapping = candidate_labels(target, row, col) for lab in cands: src_best, src_word, family, exact = page_match(lab.collapsed, source.paragraph_tokens) bg = [] for p in herbal_pages: d, _, _, _ = page_match(lab.collapsed, p.paragraph_tokens) bg.append((d, p.name)) bg.sort() rank = 1 + next(i for i, (d, name) in enumerate(bg) if name == source.name) med = median(d for d, _ in bg) # Semantic-crib score: close match, specificity to linked page, # family support, and coordinate confidence. coord_bonus = {'exact-block-coordinate': 1.0, 'row-block': 0.5, 'all-target-labels': 0.0}.get(mapping, 0.0) score = (1.0 - src_best) * 3.0 + math.log1p(family) + math.log1p(exact) + max(0.0, med-src_best) * 2.0 + coord_bonus - math.log1p(rank) * 0.35 links.append({ 'source_page': source.name, 'plant_id': source.plant_id or '', 'reference': rawref, 'target_page': target_name, 'row': row, 'col': col, 'mapping': mapping, 'label_locus': lab.locus, 'label_raw': lab.raw, 'label_collapsed': lab.collapsed, 'best_source_token': src_word, 'normalised_edit_distance': round(src_best, 4), 'family_hits_on_source': family, 'exact_hits_on_source': exact, 'source_rank_among_text_pages': rank, 'background_median_min_distance': round(med, 4), 'crib_score': round(score, 4), }) links.sort(key=lambda x: (-x['crib_score'], x['source_page'], x['label_raw'])) csv_path = args.outdir / 'plant_crib_candidates.csv' with csv_path.open('w', newline='', encoding='utf-8') as f: w = csv.DictWriter(f, fieldnames=list(links[0].keys()) if links else []) if links: w.writeheader(); w.writerows(links) # Group report by semantic link, retaining top 5 candidate labels. grouped: dict[tuple, list[dict]] = defaultdict(list) for r in links: key = (r['source_page'], r['target_page'], r['row'], r['col'], r['plant_id'], r['reference']) grouped[key].append(r) report = [] report.append('# Anchor-first plant crib attack\n') report.append('This is a first decipherment pass, not a corpus-statistics survey. It uses iconographic \u201Csame plant/root\u201D links as external semantic cribs and asks which Voynich labels can plausibly name the linked plant.\n') report.append('A candidate is stronger when its label form (or a one-edit family) appears on the linked full herbal page, is unusually specific to that page relative to the rest of the manuscript, and the iconographic coordinate maps cleanly to the label block. A high score is **not yet a translation**; it is a candidate dictionary entry to be tested on independent occurrences.\n') for key, rows in sorted(grouped.items()): source, target, row, col, plant_id, reference = key report.append(f'## {source} \u2192 {target}[{row},{col}]') if plant_id: report.append(f'Proposed plant identity in ZL metadata: **{plant_id}** ') report.append(f'Iconographic note: `{reference}`\n') report.append('| rank | candidate label | locus | map | nearest form on herbal page | edit distance | family hits | exact hits | page rank | score |') report.append('|---:|---|---|---|---|---:|---:|---:|---:|---:|') for i, r in enumerate(sorted(rows, key=lambda x: -x['crib_score'])[:5], 1): report.append(f"| {i} | `{r['label_raw']}` | `{r['label_locus']}` | {r['mapping']} | `{r[ 'best_source_token']}` | {r['normalised_edit_distance']:.3f} | {r['family_hits_on_source']} | {r[ 'exact_hits_on_source']} | {r['source_rank_among_text_pages']} | {r['crib_score']:.2f} |") report.append('') report.append('## Interpretation rule\n') report.append('Promote a candidate to a provisional codebook entry only if it survives an independent test: the same label family should recur in another depiction, a related plant-part label, or a paragraph independently associated with the same botanical entity. No candidate in this file is accepted solely because it resembles a guessed Latin plant name.\n') md_path = args.outdir / 'plant_crib_report.md' md_path.write_text('\n'.join(report), encoding='utf-8') (args.outdir / 'plant_crib_candidates.json').write_text(json.dumps(links, indent=2, ensure_ascii=False), encoding='utf-8') print(f'parsed {len(pages)} pages; {len(grouped)} iconographic links; {len(links)} label candidates') print(csv_path)