//#region ../@intlayer/cli/dist/esm/translation-alignment/computeSimilarity.mjs
const generateCharacterShingles = (text, shingleLength) => {
	const normalized = text.replace(/\s+/g, " ").trim();
	const set = /* @__PURE__ */ new Set();
	if (normalized.length < shingleLength) {
		if (normalized.length > 0) set.add(normalized);
		return set;
	}
	for (let index = 0; index <= normalized.length - shingleLength; index += 1) set.add(normalized.slice(index, index + shingleLength));
	return set;
};
const computeJaccardSimilarity = (a, b, shingleLength = 3) => {
	const setA = generateCharacterShingles(a, shingleLength);
	const setB = generateCharacterShingles(b, shingleLength);
	if (setA.size === 0 && setB.size === 0) return 1;
	const intersectionSize = Array.from(setA).filter((token) => setB.has(token)).length;
	const unionSize = new Set([...Array.from(setA), ...Array.from(setB)]).size;
	return unionSize === 0 ? 0 : intersectionSize / unionSize;
};

//#endregion
export { computeJaccardSimilarity };
//# sourceMappingURL=computeSimilarity.mjs.map