From 7feeb22fb2276a988ab3b0375e80e228733c913f Mon Sep 17 00:00:00 2001 From: martbost Date: Mon, 16 Nov 2026 13:00:47 -0600 Subject: [PATCH] Fact gate: a number proven in one sentence carries to the next sentences of the same text field (worked calculations) Co-Authored-By: Claude Opus 5.5 --- report.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/report.js b/report.js index 043838c..bbde886 100644 --- a/report.js +++ b/report.js @@ -155,8 +155,8 @@ function factcheck(report, evidenceText, keyNums) { const sum = () => { let v = prod(); while (S[i] === '+' || S[i] === '-') { const o = S[i++]; const w = prod(); v = o === '+' ? v + w : v - w; } return v; }; try { const v = sum(); return i === S.length && isFinite(v) ? v : null; } catch (x) { return null; } }; - const proveSentence = se => { - const ok = new Set(); + const proveSentence = (se, carry) => { + const ok = new Set(carry || []); const isOk = n => okNum(n.v) || ok.has(n.raw) || (!n.raw.includes('.') && !n.raw.includes(',') && n.v < 10) || (n.v > 0 && n.v < 1 && okNum(Math.round(n.v * 10000) / 100)); // 0.30 for an allowed 30% for (let pass = 0; pass < 3; pass++) { @@ -195,8 +195,9 @@ function factcheck(report, evidenceText, keyNums) { } return ok; }; - const sentences = texts.flatMap(t => strip(t).split(/(?<=[.;!?])\s+/)); - const provenIn = sentences.map(se => ({ se, ok: proveSentence(se) })); + // a number proven in one sentence can be used in the next sentences of the SAME text field (a worked calculation) + const provenIn = []; + for (const t of texts) { let carry = new Set(); for (const se of strip(t).split(/(?<=[.;!?])\s+/)) { const ok = proveSentence(se, carry); provenIn.push({ se, ok }); carry = ok; } } for (const n of numbersIn(stripped)) { const v = n.v; if (!n.raw.includes('.') && !n.raw.includes(',') && v < 10) continue; // small counts and scores