feat: improve Velum hit review and session creation

This commit is contained in:
muena
2026-12-02 08:53:37 +01:00
parent 96d5f3f57d
commit 019f6b6d7c
10 changed files with 467 additions and 95 deletions

View File

@@ -1,7 +1,8 @@
import { expect, it } from "bun:test";
import {
canonicalPerson, filenameScanText, groupReviewHits, makeTextBatches, mappingForSelection, mergePeople, reconcileDocumentHitIds,
spansBySegment, withoutPlaceholderHits, withoutWhitelistedHits, withoutWhitelistedRules,
canonicalPerson, filenameScanText, groupReviewHits, literalReviewContext, makeTextBatches, mappingForSelection,
mergePeople, reconcileDocumentHitIds, spansBySegment, textHitContexts, withoutPlaceholderHits, withoutWhitelistedHits,
withoutWhitelistedRules,
} from "../src/lib/project-review";
it("liest Unterstriche in Namen als Leerzeichen und bewahrt bekannte Codebegriffe", () => {
@@ -45,6 +46,20 @@ it("zeigt gleiche Zuordnungen einmal mit der Anzahl ihrer Vorkommen", () => {
expect(groups.find((group) => group.placeholder === "PERSON_01")?.hits.map((hit) => hit.id)).toEqual(["a", "b"]);
});
it("ordnet E-Mail-Vorkommen nach Unicode-Position zu und markiert jeweils genau den ausgewählten Treffer", () => {
const [signature, sender, recipient] = textHitContexts("😀 Von: Max\nAn: Mia\nDanke, Max", [
{ start: 26, end: 29 }, { start: 7, end: 10 }, { start: 15, end: 18 },
]);
expect(signature).toContain("**Zeile 3**");
expect(signature).toContain("Danke, ⟦Max⟧");
expect(sender).toContain("**Zeile 1**");
expect(sender).toContain("😀 Von: ⟦Max⟧");
expect(recipient).toContain("**Zeile 2**");
expect(recipient).toContain("An: ⟦Mia⟧");
const source = ["**Von:** <max@example.com>", "```", "![Bild](https://example.com/image.png)"].join("\n");
expect(literalReviewContext(source)).toBe(["````", source, "````"].join("\n"));
});
it("ordnet bestätigte Dokumenttreffer nach einem 409 nur bei identischem Vorkommen neu zu", () => {
const hit = { id: "alt", source: "Absatz 1", start: 4, end: 7, type: "PERSON",
original: "Max", context: "Herr Max antwortet" };