forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits

rag-study-scope.test.ts22 lines, 911 bytesHistoryRawDownload
1import type { RagCitation } from "@/api/client";
2import { scopeFromCitations } from "./rag-study-scope";
3
4const cite = (n: number, ders: string | null, spans: string[], pages: number[]): RagCitation => ({ n, ders, span_ids: spans, pages });
5
6it("studies the subject most citations come from, with exactly its passages", () => {
7 const scope = scopeFromCitations(
8 [cite(1, "Fizik", ["a", "b"], [4, 3]), cite(2, "Kimya", ["x"], [9]), cite(3, "Fizik", ["b", "c"], [5])],
9 " Newton'un ikinci yasası nedir? ",
10 );
11 expect(scope).toEqual({
12 ders: "Fizik",
13 span_ids: ["a", "b", "c"],
14 pages: [3, 4, 5],
15 scope_label: "Newton'un ikinci yasası nedir?",
16 });
17});
18
19it("gives no scope when no citation names a subject or carries a passage", () => {
20 expect(scopeFromCitations([cite(1, null, ["a"], [1]), cite(2, "Fizik", [], [2])])).toBeNull();
21 expect(scopeFromCitations([])).toBeNull();
22});