// Item 2's gate and the text around a quote (demo epic D2), on cases from the // D0 sample. import { test } from "node:test"; import assert from "node:assert/strict"; import { onTopicBy, quoteContext } from "./claimChecks"; const WIN: [number, string][] = [ [0, "so let's check in on the Rotten Tomato score for the acolyte"], [3, "we see it is sitting at a Wonder"], [8, "26% audience score not shocking at all"], [12, "um the show is you know basically"], [15, "getting mocked into Oblivion by anybody"], ]; test("quoteContext: the transcript's own words before and after a verbatim quote, cut at a word", () => { const c = quoteContext(WIN, "26% audience score not shocking at all um the show", { before: 40, after: 20 })!; assert.equal(c.before, "acolyte we see it is sitting at a Wonder"); assert.equal(c.after, "is you know"); // Punctuation and case do not matter; a quote that is not there is null. assert.ok(quoteContext(WIN, "Getting mocked into oblivion")); assert.equal(quoteContext(WIN, "never said this"), null); }); test("onTopicBy: the rare term in the quote or the 300 characters before it; the topic counts too", () => { const before = quoteContext(WIN, "26% audience score not shocking at all")!.before; assert.equal(onTopicBy({ quote: "26% audience score not shocking at all", before, terms: ["acolyte"] }), "acolyte"); // 300 characters of something else in between: off the question. const far = `the acolyte ${"word ".repeat(70)}`; assert.equal(onTopicBy({ quote: "26% audience score not shocking at all", before: far, terms: ["acolyte"] }), null); // A 2019 Ghostbusters video naming Star Wars in passing (D0 d k01): no. assert.equal(onTopicBy({ quote: "maybe it was Jurassic Park maybe it was Star Wars", before: "think about your favorite film franchise", terms: ["acolyte"] }), null); assert.equal(onTopicBy({ quote: "Disney's new show The Acolyte is out", before: "", terms: ["lightsaber"], topic: "the acolyte" }), "the acolyte"); // Words, not substrings. assert.equal(onTopicBy({ quote: "the acolytes of the cult", before: "", terms: ["acolyte"] }), null); });