diff --git a/scripts/import-hk-parishes.ts b/scripts/import-hk-parishes.ts index 8bb35d0..4c7d2de 100644 --- a/scripts/import-hk-parishes.ts +++ b/scripts/import-hk-parishes.ts @@ -396,9 +396,10 @@ function wordOverlap(a: string, b: string): number { const setA = new Set(a.split(' ').filter(Boolean)); const setB = new Set(b.split(' ').filter(Boolean)); if (setA.size === 0 || setB.size === 0) return 0; - let common = 0; - for (const w of setA) if (setB.has(w)) common++; - return common / Math.max(setA.size, setB.size); + let intersection = 0; + for (const w of setA) if (setB.has(w)) intersection++; + const union = setA.size + setB.size - intersection; + return intersection / union; } /**