Project Files
dist / retrieval / dedupe.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dedupeResults = dedupeResults;
const text_1 = require("../utils/text");
function dedupeResults(results) {
const seen = new Map();
for (const result of results) {
const normalized = (0, text_1.normalizeWhitespace)(result.text)
.toLowerCase()
.slice(0, 700);
const key = (0, text_1.stableHash)(normalized);
const existing = seen.get(key);
if (!existing || result.score > existing.score) {
seen.set(key, result);
}
}
return [...seen.values()];
}