// READ-ALOUD CUES (demo epic D2, round b): what the transcript around a quote // says about whose words it is, read by CODE. // // A host who covers news reads tweets, headlines, articles, reviews, chat and // letters aloud, and plays clips; an automatic transcript has no quotation // marks, and a small model cannot tell the reading from the speaking (D0 and // round a, 11 Nov 2026: 60 of 185 graded quotes were not the host's words; the // model's own speaker/stance answer missed most of them). The words that // introduce a reading are in the transcript, though: "one tweet that put it // really good", "19,000 likes here it is", "you see this clip from", "he // writes", "according to", "this is from … shout out good take". This module // looks for them: in the 400 characters before the quote, in the quote, and // in the 150 after. // // A cue is evidence, not a verdict: the caller drops the item or keeps it // flagged "check by ear" (settings: generation.localSweep.readAloud). // // The list is derived from the graded claims of D0 and round a (the grader's // `not_him`), not from a guess; each pattern's comment names a claim it reads. // Round b's own first runs (12 Nov 2026, eight sweeps graded) added the words // said right before a quote ("the showrunner says", "chris gore writing", "you // can see", "lucasfilm also revealed that"), "this via " after it and // "going on to say", and took "email" out (he talks about the emails Wizards // sent him in his own words). What no pattern catches is a headline or an // article read with nothing announcing it — about a third of the readings. // What a sweep does with a quote that has a cue: nothing (`off`), keep it // marked "check by ear" (`flag`), or leave it out (`drop`). export { READ_ALOUD_MODES, type ReadAloudMode } from "../../../generationSettings"; // The claim's flag in report.json (a pill on its card; at most 60 characters). export const READ_ALOUD_FLAG = "check by ear: may be read aloud"; export type ReadAloudCue = { // The pattern's name (stable: stored beside the item, shown in the trace). cue: string; where: "before" | "quote" | "after"; // The transcript's words that matched. match: string; }; type Pattern = { cue: string; re: RegExp; near?: number }; // Before the quote. `near`: only in the last N characters (an attribution verb // far back introduces something else). const BEFORE: Pattern[] = [ // "one tweet that put it really good", "kurt tweeted along", "retweets" { cue: "tweet", re: /\b(?:re)?tweet(?:s|ed|ing)?\b|\bquote tweet/, near: 250 }, // "453 comments 371 likes", "19,000 likes here it is" { cue: "likes", re: /\b\d[\d,.]*\s*(?:(?:k|thousand|million)\s*)?(?:likes|retweets|replies|comments|reposts|upvotes)\b/ }, // "here's another article", "you can see the article from just a few hours ago" { cue: "article", re: /\b(?:here'?s|see|saw|seen|read|reading|reads|whole|another|according to) (?:\w+ ){0,2}(?:article|headline|op-?ed|press release|blog post|write-?up|story|report)s?\b/ }, // "oh another comment mods made … made it clear that", "left a slanderous libel review" { cue: "comment", re: /\b(?:another|this|that|one|top|first|next) (?:comment|reply|review|post)\b|\b(?:leave|left|leaves|wrote|writes|posted) an? (?:\w+ ){0,3}(?:comment|review|reply)\b/, near: 300 }, // "this is the letter he wrote them", "in his statement", "another comment mod made" { cue: "letter", re: /\b(?:letter|statement|memo|announcement)\b/, near: 200 }, // "you see this clip from looper", "here's the clip", "queue up the audio" { cue: "clip", re: /\b(?:clip|audio|footage|trailer)\b/, near: 300 }, // "according to some", "according to persistent rumors" { cue: "according to", re: /\baccording to\b/, near: 300 }, // "here shad writes from", "he wrote", "it says", "she replies", "wwe pro also added", // "the customer goes on to say", "their reports allege", "producer claims" { cue: "writes", re: /\b(?:he|she|they|it|who|which|that|this|\w+ also|[a-z]+ [a-z]+) (?:writes?|wrote|replies|replied|tweeted|posted|added|adds|alleges?|goes on to say|going on to say|went on to say|responds|responded)\b|\b(?:it|he|she|this|that|which|article|headline|tweet|post|review|comment|caption|title) (?:says|said|reads|read|states|stated|claims|claimed)\b/, near: 300, }, // "to which he replies", "quote", "titled" right before it { cue: "titled", re: /\b(?:to which (?:he|she|they) repl\w+|quote|unquote|and i quote|titled|entitled|captioned|headlined|reads)\s*$/ }, // Right before the quote: "who heads up the show says", "he said", "now we have chris gore writing", // "you can see", "when you see", "they include phrases such as" (round b's own runs, 12 Nov). { cue: "says", re: /(? p.split(" ")); function phraseInFirstWords(after: string): string | null { const words = after.split(/[^a-z0-9_]+/).filter(Boolean).slice(0, AFTER_WORDS + 4); for (let i = 0; i <= Math.min(AFTER_WORDS, words.length - 1); i++) { for (const p of AFTER_PHRASES) { if (p.every((w, j) => words[i + j] === w)) return words.slice(0, i + p.length).join(" "); } } return null; } const esc = (s: string) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const lower = (s: string) => s.toLowerCase().replace(/[’‘]/g, "'").replace(/\s+/g, " ").trim(); export const READ_ALOUD_BEFORE = 400; export const READ_ALOUD_AFTER = 150; // A quote is at most 40 words in a sweep; the cap keeps a caller's long text linear and short. export const READ_ALOUD_QUOTE = 2000; // The cues around one quote: none = nothing says it is read aloud. // `hosts`: the names of the person the report is about (lowercase); a quote // that names him in the third person is somebody else's words about him. export function readAloudCues(o: { before: string; quote: string; after: string; hosts?: readonly string[] }): ReadAloudCue[] { const out: ReadAloudCue[] = []; // Sliced before `lower` too (whitespace runs collapse, so twice the window is read). const before = lower(o.before.slice(-READ_ALOUD_BEFORE * 2)).slice(-READ_ALOUD_BEFORE); const after = lower(o.after.slice(0, READ_ALOUD_AFTER * 2)).slice(0, READ_ALOUD_AFTER); const quote = lower(o.quote.slice(0, READ_ALOUD_QUOTE * 2)).slice(0, READ_ALOUD_QUOTE); const add = (cue: string, where: ReadAloudCue["where"], match: string) => { if (!out.some((c) => c.cue === cue)) out.push({ cue, where, match: match.trim() }); }; for (const p of BEFORE) { const text = p.near ? before.slice(-p.near) : before; const m = p.re.exec(text); if (m) add(p.cue, "before", m[0]); } for (const p of AFTER) { const m = p.re.exec(p.near ? after.slice(0, p.near) : after); if (m) add(p.cue, "after", m[0]); } const said = phraseInFirstWords(after.slice(0, 120)); if (said) add("reaction (after)", "after", said); // In the quote: the host named in the third person ("jeremy hambly was // banned by wizards", "hambly has in the past gone after"), a chat line // ("sologamer5 says hey jeremy"), a "quote" spoken inside it. const names = (o.hosts ?? []).map((h) => lower(h)).filter((h) => h.length >= 3); for (const h of names) { const re = new RegExp(`\\b${esc(h)}(?:'s)?\\b`); const m = re.exec(quote); if (!m) continue; // His own sign-on: "jeremy here from the quartering", "i'm jeremy", "my name is". // (the transcript hears "jeremy here from" as "jeremy are from", "jeremy hair from") const self = new RegExp( `\\b(?:i'?m|i am|my name(?: is)?|it'?s|this is|papa|here from|here with)\\s+(?:\\w+\\s+){0,2}${esc(h)}\\b|\\b${esc(h)}(?:\\s+\\w+){0,2}\\s+(?:here|hear|hair|are) (?:from|with|and)\\b|\\b(?:from|on|at|to|of|with) (?:the )?${esc(h)}\\b`, ).test(quote); if (!self) add("names the host", "quote", m[0]); } const chat = /^\w+ says\b/.exec(quote) ?? /\bhey (?:\w+ )?(?:been a while|love (?:the|your)|big fan)\b/.exec(quote); if (chat) add("chat", "quote", chat[0]); const q = /\bquote\b/.exec(quote); if (q) add("quote", "quote", q[0]); // Reported speech inside the quote: "now they're saying if you rely upon misinformation". const rs = /\b(?:they'?re|they are|he'?s|she'?s|he is|she is|it'?s|is|are) saying\b|\b(?:it|article|headline|tweet|post|review) (?:says|reads)\b/.exec(quote); if (rs) add("saying", "quote", rs[0]); return out; } // One line for a log, a trace or a reason: `tweet (“one tweet”), likes (“19,000 likes”)`. export function cuesLine(cues: readonly ReadAloudCue[]): string { return cues.map((c) => `${c.cue} (${c.where === "before" ? "" : `${c.where}: `}“${c.match}”)`).join(", "); }