const el=id=>document.getElementById(id); const pct=v=>(100*v).toFixed(2)+'%'; const fixed=v=>Number(v).toFixed(2); function rows(id,values,highlight=-1){const body=el(id);body.replaceChildren();values.forEach((values,i)=>{const row=document.createElement('tr');if(i===highlight)row.className='selected';for(const value of values){const cell=document.createElement('td');cell.textContent=value;row.append(cell)}body.append(row)})} let study; function drawChart(){const key=el('comparisonMetric').value,higher=key.includes('exact'),models=Object.entries(study.models).sort((a,b)=>(higher?-1:1)*(a[1].final[key]-b[1].final[key]));const scale=Math.max(...models.map(([,m])=>m.final[key]))*1.1;const chart=el('modelChart');chart.replaceChildren();for(const [i,[variant,m]] of models.entries()){const row=document.createElement('div');row.className='chart-row';const name=document.createElement('div');name.className='chart-name';name.textContent=m.label;const rank=document.createElement('small');rank.textContent=`${i+1} / 3 by this metric`;name.append(rank);const track=document.createElement('div');track.className='chart-track';const bar=document.createElement('div');bar.className='chart-bar';bar.style.setProperty('--bar',(100*m.final[key]/scale).toFixed(3)+'%');bar.style.setProperty('--tone',variant==='candidate'?'#7159c1':variant==='pilot'?'#a491ce':'#c7bfd9');track.append(bar);const value=document.createElement('div');value.className='chart-value';value.textContent=pct(m.final[key]);row.append(name,track,value);chart.append(row)}el('chartScope').textContent=`Zero-origin bars, shared scale 0–${pct(scale)}. ${higher?'Higher':'Lower'} is better. Point-estimate order within this study only.`} async function load(){try{const response=await fetch('capped-study-results-20261015.json');const external=await fetch('benchmark-context-20261015.json');if(!response.ok||!external.ok)throw new Error('Research evidence snapshot is unavailable.');study=await response.json();const context=await external.json();const selected=study.models[study.selection],paired=study.paired_original_selected;el('snapshotDate').textContent='Frozen results snapshot · '+new Date(study.generated_utc).toLocaleDateString(undefined,{day:'numeric',month:'long',year:'numeric'})+' · Windows RTX 3050';el('localRank').textContent=1+Object.values(study.models).filter(m=>m.final.nfc_micro_cerfixed(100*x)).join(' to ')+' pp';el('parityCount').textContent=study.api_parity.api_requests+' / '+study.api_parity.api_requests;for(const [id,key] of [['trainN','train'],['valN','validation'],['testN','final-test']])el(id).textContent=study.protocol[key].count.toLocaleString();const entries=Object.entries(study.models);rows('finalTable',entries.map(([,m])=>[m.label,m.final.examples,...['raw_micro_cer','nfc_micro_cer','raw_micro_wer','nfc_micro_wer','raw_exact_match','nfc_exact_match'].map(k=>pct(m.final[k]))]),entries.findIndex(([key])=>key===study.selection));el('validationGap').textContent=`Validation exact match ${pct(selected.validation.raw_exact_match)}; independent final exact match ${pct(selected.final.raw_exact_match)}. The ${fixed(100*(selected.validation.raw_exact_match-selected.final.raw_exact_match))} pp held-out gap is preserved. All raw/NFC aggregate pairs coincide on this sample.`;const labels={raw_cer_reduction:'Raw CER reduction',nfc_cer_reduction:'NFC CER reduction',raw_wer_reduction:'Raw WER reduction',nfc_wer_reduction:'NFC WER reduction',raw_exact_gain:'Raw exact gain',nfc_exact_gain:'NFC exact gain'};rows('intervalTable',Object.entries(labels).map(([k,label])=>[label,fixed(100*paired.point_differences[k]),paired.intervals_95[k].map(x=>fixed(100*x)).join(' to ')]));const original=study.models.original.subgroups;rows('subgroupTable',Object.keys(selected.subgroups).filter(k=>!k.startsWith('document:')&&!k.startsWith('error:')&&original[k]).sort().map(k=>{const b=original[k],a=selected.subgroups[k];return[k,a.examples,...['micro_cer','micro_wer','raw_exact_match'].flatMap(metric=>[pct(b[metric]),pct(a[metric])])]}));rows('resourceTable',entries.map(([,m])=>[m.label,m.timing.latency_median_seconds.toFixed(3)+' s',m.timing.latency_p95_seconds.toFixed(3)+' s',(m.timing.peak_allocated_vram_bytes/2**30).toFixed(3)+' GiB',Math.round(m.diagnostics.repetition_candidate_rate*m.final.examples),m.diagnostics.truncated_count]));el('diagnosticNote').textContent='Selected final: zero script-contamination, refusal, malformed, repetition, truncation and abstention flags. These heuristics do not make the remaining transcription errors disappear.';rows('vendorTable',context.vendor_hw_telugu.map((r,i)=>[i+1,r.model,fixed(r.score)]));rows('familyTable',context.vendor_families.map(r=>[r.task,fixed(r.score),r.unit]));rows('omniTable',context.omnidoc_full_top5.map((r,i)=>[i+1,r.model,fixed(r.score)]));rows('icdarTable',context.icdar_telugu.map((r,i)=>[i+1,r.team,fixed(r.crr),fixed(r.wrr)]));rows('paperTable',context.paper_telugu.map(r=>[r.domain,r.model,pct(r.wer/100),pct(r.cer/100)]));el('artifactHashes').textContent=JSON.stringify({selection_sha256:study.selection_sha256,final_summary_sha256:study.final_summary_sha256,manifests:study.protocol,final_predictions:Object.fromEntries(entries.map(([k,m])=>[k,m.predictions_sha256]))},null,2);drawChart();el('comparisonMetric').addEventListener('change',drawChart)}catch(error){el('analysisError').hidden=false;el('analysisError').textContent=error.message;}} load();