File size: 4,597 Bytes
3ecef03
 
 
 
 
 
 
1
2
3
4
5
6
7
8
const $=s=>document.querySelector(s);let data,current,threshold;
const fmt=x=>x<.0001?x.toExponential(2):x.toFixed(4);
function mode(c){return c.set==='stress'?'stress':c.split}
function populate(id){const rows=data.cases.filter(c=>mode(c)===$('#dataset').value);$('#case').replaceChildren(...rows.map(c=>{const o=document.createElement('option');o.value=c.case_id;o.textContent=c.case_id+' · '+(c.mutation||c.condition).replaceAll('_',' ');return o}));if(id)$('#case').value=id;show($('#case').value)}
function show(id){current=data.cases.find(c=>c.case_id===id);const c=current;$('#source').src=c.region;$('#render').src=c.render_image;$('#fullPage').href=c.page;$('#ocr').textContent=c.text;$('#caseMeta').textContent=c.template_family+' · '+c.condition.replaceAll('_',' ');$('#candidateKind').textContent=c.set==='stress'?'Controlled candidate':'Actual model output';$('#ruleTitle').textContent=c.rule_issues.length?'Check failed':'Checks pass';$('#ruleTitle').className=c.rule_issues.length?'bad':'';$('#ruleDetail').textContent=c.rule_issues.length?c.rule_issues.join(', ').replaceAll('_',' '):'All four fields are present. Currency is consistent. Subtotal + shipping + tax equals total.';$('#score').textContent=c.score===null?'Unavailable':fmt(c.score);$('#scoreBar').style.width=100*(c.score||0)+'%';const review=c.rule_issues.length||c.score===null||c.score<data.summary.operating_point.threshold;$('#route').textContent=review?'Send to review':'Pass the OCR check';$('#route').className=review?'bad':'';$('#routeDetail').textContent='Review on a rule failure or a score below '+data.summary.operating_point.threshold.toFixed(6)+'.';$('#truth').textContent='Ground truth: '+(c.correct?'critical fields match':'critical fields differ');$('#truth').className='badge'+(c.correct?'':' bad');$('#audit').textContent=JSON.stringify({case:c.case_id,set:c.set,split:c.split,source_sha256:c.region_sha256||c.sha256_region,reference_fields:c.reference_fields,extracted_fields:c.extracted,score:c.score,rule_issues:c.rule_issues,ocr_including_preprocessing_ms:c.ocr_ms,verifier_forward_ms:c.verifier_ms,verifier_including_preprocessing_ms:c.verifier_total_ms,note:'Verifier timings exclude candidate rendering. Shared GPU; recorded inference.'},null,2);document.querySelectorAll('[data-case]').forEach(b=>b.classList.toggle('active',b.dataset.case===id))}
function updateThreshold(){const rows=data.cases.filter(c=>c.set==='natural'&&c.split==='test');const reviewed=rows.filter(c=>c.rule_issues.length||c.score===null||c.score<threshold);const caught=reviewed.filter(c=>!c.correct).length;$('#thresholdLabel').textContent=threshold.toFixed(6);$('#reviewCount').textContent=reviewed.length+' / 80';$('#caughtCount').textContent=caught+' / 3';$('#escapedCount').textContent=3-caught;const n=80-reviewed.length;$('#risk').textContent=n?`${3-caught} incorrect accepted out of ${n} accepted regions. This sample does not establish zero production risk.`:'Every region is routed to review.'}
fetch('evidence.json').then(r=>{if(!r.ok)throw Error('Evidence unavailable');return r.json()}).then(d=>{data=d;threshold=d.summary.operating_point.threshold;$('#threshold').value=threshold;populate('invoice-090-consistent_amounts');updateThreshold();const c=d.cases.find(c=>c.case_id==='invoice-090-reference');const amount=new Intl.NumberFormat('en-US',{style:'currency',currency:c.reference_fields.currency}).format(c.reference_fields.total/100);$('#businessExample').textContent=`The correctly transcribed total for DVL-0090 is ${amount}. If a separate purchase-order check expects ${new Intl.NumberFormat('en-US',{style:'currency',currency:c.reference_fields.currency}).format((c.reference_fields.total-10000)/100)}, route the difference to a business reviewer even when the visual score is high. This PO difference is a constructed workflow example.`;$('#dataset').addEventListener('change',()=>populate());$('#case').addEventListener('change',e=>show(e.target.value));document.querySelectorAll('[data-case]').forEach(b=>b.addEventListener('click',()=>{const c=d.cases.find(c=>c.case_id===b.dataset.case);$('#dataset').value=mode(c);populate(c.case_id)}));$('#threshold').addEventListener('input',e=>{threshold=Number(e.target.value);updateThreshold()});$('#reset').addEventListener('click',()=>{threshold=d.summary.operating_point.threshold;$('#threshold').value=threshold;updateThreshold()});fetch('walkthrough.mp4',{method:'HEAD'}).then(r=>{if(r.ok)$('#film').hidden=false}).catch(()=>{})}).catch(e=>{$('#workbench').textContent='Could not load recorded evidence. Please reload. '+e.message});