NODEDC_1C/llm_normalizer/backend/tests/assistantOrganizationMatche...

38 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it } from "vitest";
import {
mergeKnownOrganizations,
normalizeOrganizationScopeSearchText,
resolveOrganizationSelectionFromMessage,
scoreOrganizationMentionInMessage
} from "../src/services/assistantOrganizationMatcher";
describe("assistant organization matcher", () => {
it("deduplicates known organizations by normalized search key", () => {
expect(
mergeKnownOrganizations([
'ООО "Альтернатива Плюс"',
"ооо альтернатива плюс",
"ООО Лайсвуд"
])
).toEqual(['ООО "Альтернатива Плюс"', "ООО Лайсвуд"]);
});
it("matches incomplete or reordered organization mention against live candidates", () => {
const resolved = resolveOrganizationSelectionFromMessage("дай что сегодня на складе в конторе ссыт кот", [
"ООО КОТ ССЫТ ВО ДВОРЕ",
"ООО Альтернатива Плюс"
]);
expect(resolved).toBe("ООО КОТ ССЫТ ВО ДВОРЕ");
});
it("scores direct and fuzzy token overlap above ambiguity threshold", () => {
const score = scoreOrganizationMentionInMessage(
normalizeOrganizationScopeSearchText("что на складе конторы альтернатива"),
'ООО "Альтернатива Плюс"'
);
expect(score).toBeGreaterThanOrEqual(90);
});
});