Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 74ed813330e932220c7fee73c9b2b2faf7248936
parent ed72655a62afbc65b65e46bf299e571eaa4d530e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 18:40:57 -0500

umtool screens, round 3: a line take says the line's words in order -- no extra word, one missing at most, never a negation

postThreadRead.mjs lineTakeProblem (saysLine is its null): the take's words are the line's
said words in order, none more, at most one left out and never a negation (not, no,
never, -n't…); a shape, an @handle, an anonymous handle or a redacted term anywhere in it
refuses it -- the terms now the project's AND the post's own (post-redact.mjs termsFor).
The refusal says which. Tests: lib/report/postScreens.test.mjs "ROUND 3 (q3)…" and
"ROUND 3: the thread read refuses a line take that says a per-post redaction term…".

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mumtool/lib/report/postScreens.test.mjs | 26+++++++++++++++++++++++++-
Mumtool/lib/report/postThreadRead.mjs | 56++++++++++++++++++++++++++++++++++++--------------------
2 files changed, 61 insertions(+), 21 deletions(-)

diff --git a/umtool/lib/report/postScreens.test.mjs b/umtool/lib/report/postScreens.test.mjs @@ -272,7 +272,7 @@ test("MUST 2 (q1): a line take must say the line -- at most one word more or les assert.equal(saysLine("please call me at secretkid tonight after work ok", line), false, "a name-like extra word, with no set given (q1)"); assert.equal(saysLine("please call me at secretkid tonight after work ok", line, { handles: ["secretkid"] }), false, "an anonymous handle, bare"); assert.equal(saysLine("please call me at Jenny tonight after work ok", line, { terms: ["Jenny"] }), false, "a redaction term"); - assert.equal(saysLine("please call me at tonight after work, okay", line), true, "one word off (ASR slack)"); + assert.equal(saysLine("please call me at tonight after work, okay", line), false, "a word swapped is an extra word (round 3: none allowed)"); assert.equal(saysLine("please call me tonight after work ok", line), true, "one word fewer"); assert.equal(saysLine("please call me tonight after ok", line), false, "two fewer"); }); @@ -282,3 +282,27 @@ test("SHOULD (re-import): the batch import keeps a part's line and speaker", () assert.equal(p.line, "hop on it"); assert.equal(p.speaker, "TheQuartering"); }); + +test("ROUND 3 (q3): a line take says the line's words IN ORDER -- no extra word, at most one missing, never a negation missing", () => { + assert.equal(saysLine("my pin is nine thanks", "my pin is thanks"), false, "a spelt digit as the extra word"); + assert.equal(saysLine("I did not take it", "I did take it"), false, "meaning flipped by one short word"); + assert.equal(saysLine("I never said no", "I never said yes"), false, "a substitution"); + assert.equal(saysLine("ask jenny about it", "ask about it"), false, "a redacted short name, with no term given"); + assert.equal(saysLine("ask savvy about it", "ask about it", { handles: ["madamsavvy"] }), false, "an anonymous author's short display name"); + assert.equal(saysLine("ask JENNY about it", "ask about it", { terms: ["jenny"] }), false); + assert.equal(saysLine("take it about ask", "ask about take it"), false, "out of order"); + assert.equal(saysLine("I did take it", "I did not take it"), false, "a negation left out"); + assert.equal(saysLine("I didn't take it", "I didn't take it"), true); + assert.equal(saysLine("I take it", "I didn't take it"), false, "an n't word left out"); + assert.equal(saysLine("I did take it", "I did take it now"), true, "one word fewer (not a negation)"); + assert.equal(saysLine("Ask about it.", "ask about it"), true, "case and punctuation"); +}); + +test("ROUND 3: the thread read refuses a line take that says a per-post redaction term (termsFor, not only the project's)", async () => { + const item = { ...ITEM, screens: [DM([{ who: "TheQuartering", text: "You can't be this dumb" }])] }; + const p = await project("r3", item); + const e = (await read(p)).timeline[0]; + // The post's own markup term (the item's, not the project's list) -- the take says it, the line as said leaves it out. + const red = { ...NO_RED, markup: { [e.post]: { redact: [{ term: "dumb" }] } } }; + await assert.rejects(() => threadTake(p, e, { red, ask: stubAsk([]), lanes: null, postTake: 1, lineTakes: { "screen:s1:0": 2 } }), /--line-take screen:s1:0=2: its take does not say line 0 of screen s1 \(it says a redacted term\)/); +}); diff --git a/umtool/lib/report/postThreadRead.mjs b/umtool/lib/report/postThreadRead.mjs @@ -61,7 +61,7 @@ import { POST_PART_GAP, draftScript, nextTakeNumber, pickedTake, postIdOf, postN import { chronoPieces } from "umtool-report-to-video/post-thread"; import { cardText, parentsOf } from "umtool-report-to-video/post-item"; import { planContext } from "umtool-report-to-video/post-conversation"; -import { spokenRead } from "umtool-report-to-video/post-redact"; +import { spokenRead, termsFor } from "umtool-report-to-video/post-redact"; import { readSpeedOf, resolvePieceVoice } from "umtool-report-to-video/post-say"; import { SCREEN_LINE_GAP, parseScreenRole, screenWho, shapeSpans } from "umtool-report-to-video/post-screens"; import { readManifest } from "../projects/report.mjs"; @@ -235,9 +235,11 @@ export function threadReadPlan(manifest, e, { red = null, map = {}, cast = {}, i // A take that does not say the line is REFUSED, never played as it. const words = norm(lt.take.said) || norm(lt.take.script); const anonHandles = red?.anon instanceof Map ? [...red.anon.keys()] : Object.keys(red?.anon ?? {}).filter((x) => x !== "postIds"); - if (!saysLine(words, said.text, { handles: anonHandles, terms: (red?.terms ?? []).map((x) => (typeof x === "string" ? x : x?.term)).filter(Boolean) })) { + // The project's terms AND the post's own (its markup): what the card blanks, a take never says. + const why = lineTakeProblem(words, said.text, { handles: anonHandles, terms: termsFor(e, red).map((x) => x.term) }); + if (why) { const sp = /^screen:([a-z0-9-]+):(\d+)$/.exec(p.role); - throw new ThreadReadError(`--line-take ${p.role}=${lt.n}: its take does not say line ${sp[2]} of screen ${sp[1]} (its words are another line's, or the line changed) -- record that line, or name the take that reads it`); + throw new ThreadReadError(`--line-take ${p.role}=${lt.n}: its take does not say line ${sp[2]} of screen ${sp[1]} (it says ${why === "other words" ? "other words than the line: another line's, more words, or the line changed" : why}) -- record that line, or name the take that reads it`); } pieces.push({ role: p.role, handle, who: p.who, speaker: str(p.who), date: null, voice: takeVoiceOf(lt.take), from: "take", written, line: written, text: words, lexicon: [], slurs: lt.take.slurs ?? null, take: { n: lt.n, id: takeIdOf(lt.take), file: lt.take.file, ...(lt.take.engine ? { engine: lt.take.engine } : {}) } }); continue; @@ -307,33 +309,47 @@ export function characterNames(L) { return out; } +/** A NEGATION: a line that has one, a take must say it (it is never the word left out). */ +const NEGATION_RE = /^(?:not|no|nope|never|nor|none|nothing|nobody|nowhere|neither|cannot|.+n't|(?:do|does|did|ca|wo|is|are|was|were|could|should|would|have|has|had|ai|must|need|might)nt)$/u; + /** - * Whether a take's words SAY a line, pure: word for word (normalized), with at most ONE word more (a short plain - * word: at most five lower-case letters) and one word fewer (a recording's or a transcript's slack) -- and the take holds no shape (an e-mail, a number: shapeSpans), no @handle, - * no anonymous handle (`handles`) and no redacted term (`terms`) anywhere in what it says. A take of another line, of - * the post, of an older line, or one that says what the card masks, does not. + * WHAT A LINE TAKE SAYS AMISS, pure: null when its words SAY the line -- the line's said words IN ORDER, normalized + * (case, edge punctuation), NO word more, at most one word fewer and never a negation (not, no, never, -n't…) -- else + * why not: "a shape" (an e-mail, a number: shapeSpans), "a handle" (an @handle, an anonymous author's `handles`), "a + * redacted term" (`terms`: the project's and the post's own, post-redact.mjs termsFor), "other words". */ -export function saysLine(takeWords, lineWords, { handles = [], terms = [] } = {}) { - if (shapeSpans(str(takeWords)).length) return false; - const keys = (t) => str(t).toLowerCase().split(/\s+/).map((w) => w.replace(/^[^\p{L}\p{N}@]+|[^\p{L}\p{N}]+$/gu, "")).filter(Boolean); +export function lineTakeProblem(takeWords, lineWords, { handles = [], terms = [] } = {}) { + if (shapeSpans(str(takeWords)).length) return "a shape"; + const keys = (t) => str(t).toLowerCase().replace(/[’‘]/g, "'").split(/\s+/).map((w) => w.replace(/^[^\p{L}\p{N}@]+|[^\p{L}\p{N}]+$/gu, "")).filter(Boolean); const a = keys(takeWords); const b = keys(lineWords); - if (!a.length || !b.length) return false; const banned = new Set(handles.map((h) => String(h).replace(/^@+/, "").toLowerCase())); + if (a.some((w) => w.startsWith("@") || banned.has(w))) return "a handle"; const termRes = terms.map((t) => new RegExp(`(?<![\\p{L}\\p{N}])${String(t).replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}])`, "iu")); - if (a.some((w) => w.startsWith("@") || banned.has(w)) || termRes.some((re) => re.test(str(takeWords)))) return false; - const pool = new Map(); - for (const w of b) pool.set(w, (pool.get(w) ?? 0) + 1); - const extras = []; + if (termRes.some((re) => re.test(str(takeWords)))) return "a redacted term"; + if (!a.length || !b.length || a.length > b.length || b.length - a.length > 1) return "other words"; + // In order, every word the line's; one word of the line may be left out -- never a negation. + let i = 0; + let skipped = null; for (const w of a) { - if ((pool.get(w) ?? 0) > 0) pool.set(w, pool.get(w) - 1); - else extras.push(w); + while (i < b.length && b[i] !== w) { + if (skipped !== null) return "other words"; + skipped = b[i]; + i += 1; + } + if (i >= b.length) return "other words"; + i += 1; } - const missing = [...pool.values()].reduce((x, y) => x + y, 0); - // The one word of slack is a SHORT plain word ("okay" for "ok", "uh"): never a name, a handle or a number. - return extras.length <= 1 && extras.every((w) => /^\p{Ll}{1,5}$/u.test(w)) && missing <= 1; + if (i < b.length) { + if (skipped !== null || i + 1 < b.length) return "other words"; + skipped = b[i]; + } + return skipped !== null && NEGATION_RE.test(skipped) ? "other words" : null; } +/** Whether a take's words SAY a line (lineTakeProblem's null). */ +export const saysLine = (takeWords, lineWords, o = {}) => lineTakeProblem(takeWords, lineWords, o) === null; + /** A take's voice as a thread read's label says it: its voice (or recorded label) without an engine ("am_michael", "operator"). */ export function takeVoiceOf(t) { const v = str(t?.voice) || str(t?.label) || (t?.engine === "recorded" ? "recorded" : "take");