run_fifth_record_prospective_033.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 1 run_fifth_record_prospective_033.py Source: /Voynich/Voynich_FIFTH_RECORD_ATTACK_033_034_reproducibility.zip!/run_fifth_record_prospective_0 33.py SHA-256: db0bd93aa841f51717612fb61f84b8db76d3dacf9b88485e62d198ff421f1763 !/usr/bin/env python3 """FIFTH-RECORD-PROSPECTIVE-033: recover omitted coordinate lines without ordinal constraint.""" from pathlib import Path from collections import defaultdict,Counter from difflib import SequenceMatcher import hashlib,json import numpy as np,pandas as pd import run_geometric_expansion_link_030 as g30 import run_anonymous_record_decompression_032 as d32 ROOT=Path(__file__).resolve().parent;OUT=ROOT/'fifth_record_prospective_033';OUT.mkdir(exist_ok=True) MIN_RATIO=.55;MIN_MARGIN=.10 def recover_unrestricted(existing): txt=g30.eva_prose_lines();added={};audit=[] for p in g30.BOXDIR.glob('*.js'): fol=p.stem if fol not in txt:continue vis=g30.box_lines(p);lines=txt[fol];M=np.zeros((len(lines),len(vis))) for i,(ln,t) in enumerate(lines): for j,v in enumerate(vis):M[i,j]=SequenceMatcher(a=[g30.collapse(x['word']) for x in v],b=[g30.collapse(x) for x in t],autojunk=False).ratio() for i,(ln,t) in enumerate(lines): if (fol,ln) in existing or not len(vis):continue j=int(M[i].argmax());best=float(M[i,j]);second=float(np.partition(M[i],-2)[-2]) if len(vis)>1 else 0 mutual=int(M[:,j].argmax())==i accepted=best>=MIN_RATIO and best-second>=MIN_MARGIN and mutual audit.append({'folio':fol,'line':ln,'visual_line_index':j,'ratio':best,'margin':best-second,'mutual_b est':int(mutual),'accepted':int(accepted)}) if accepted: v=vis[j];added[(fol,ln)]=(min(b['x'] for b in v),min(b['y'] for b in v),max(b['x']+b['w'] for b in v),max(b['y']+b['h'] for b in v)) return added,pd.DataFrame(audit) def selected(q): scores=[] for c in q['cand']: _,y0,_,y1=c['box'];scores.append(-abs((y0+y1)/2/837-q['qy']/837)) j=int(np.argmax(scores));c=q['cand'][j] return {'folio':q['folio'],'key':q['key'],'line':c['line'],'hit':j in q['pos'],'full':list(c['payloads']),'residual':[x for x in c['payloads'] if x!=q['key']],'vertical_distance':-scores[j]} def main(): lb=g30.aligned_label_boxes();base=g30.aligned_prose_lines();added,audit=recover_unrestricted(base);coor ds={**base,**added} old={w:{(q['folio'],q['key']) for q in g30.build(w,lb,base)} for w in ('ZL','GC')};new={};rows=[] for w in ('ZL','GC'): qs=[q for q in g30.build(w,lb,coords) if (q['folio'],q['key']) not in old[w]];new[w]={} for q in qs: r=selected(q);r['witness']=w;rows.append(r);new[w][(r['folio'],r['key'])]=r common=sorted(set(new['ZL'])&set(new['GC']));pairs=[] for k in common: z,g=new['ZL'][k],new['GC'][k];jac=d32.multiset_jaccard(z['residual'],g['residual']);lcs=d32.lcs_ratio( z['residual'],g['residual']) pairs.append({'folio':k[0],'key':k[1],'zl_line':z['line'],'gc_line':g['line'],'zl_hit':int(z['hit']),' gc_hit':int(g['hit']),'both_hit':int(z['hit'] and g['hit']),'zl_residual':' | '.join(z['residual']),'gc_residual':' | '.join(g['residual']),'multiset_jaccard':jac,'ordered_lcs_ratio' :lcs}) p=pd.DataFrame(pairs);qual=p[(p.both_hit==1)&(p.multiset_jaccard>=.50)&(p.ordered_lcs_ratio>=.75)] if len(p) else p passed=len(qual)>=1