hezarfen_frontend
Clone
https://git.tahinli.com/Hezarfen/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
| 1 | import type { RagCitation } from "@/api/client"; |
| 2 | import { scopeFromCitations } from "./rag-study-scope"; |
| 3 | |
| 4 | const cite = (n: number, ders: string | null, spans: string[], pages: number[]): RagCitation => ({ n, ders, span_ids: spans, pages }); |
| 5 | |
| 6 | it("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 | |
| 19 | it("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 | }); |