From 82c66ba3f0e1c49bb88d39166bb2d5dcf1efcaed Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Thu, 25 Dec 2025 10:30:12 -0500 Subject: [PATCH] Normalize for resolveTerm --- script.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/script.js b/script.js index b8479be..dc336a0 100644 --- a/script.js +++ b/script.js @@ -142,46 +142,46 @@ const specialCaseMap = { }; const resolveTerm = (term) => { - const normalized = term.replace(/’/g, "'"); + const normalized = term.replace(/'/g, "'"); const special = specialCaseMap[normalized]; if (special && entryMap.has(special)) { return special; } - if (entryMap.has(term)) { - return term; + if (entryMap.has(normalized)) { + return normalized; } - const lower = term.toLowerCase(); + const lower = normalized.toLowerCase(); const candidates = []; // Singularize if (lower.endsWith("ies")) { - candidates.push(term.slice(0, -3) + "Y"); + candidates.push(normalized.slice(0, -3) + "Y"); } if (lower.endsWith("ves")) { - candidates.push(term.slice(0, -3) + "F"); - candidates.push(term.slice(0, -3) + "FE"); + candidates.push(normalized.slice(0, -3) + "F"); + candidates.push(normalized.slice(0, -3) + "FE"); } if (lower.endsWith("es")) { - candidates.push(term.slice(0, -2)); + candidates.push(normalized.slice(0, -2)); } if (lower.endsWith("s")) { - candidates.push(term.slice(0, -1)); + candidates.push(normalized.slice(0, -1)); } // Pluralize if (lower.endsWith("y") && !/[aeiou]y$/.test(lower)) { - candidates.push(term.slice(0, -1) + "IES"); + candidates.push(normalized.slice(0, -1) + "IES"); } if (lower.endsWith("f")) { - candidates.push(term.slice(0, -1) + "VES"); + candidates.push(normalized.slice(0, -1) + "VES"); } if (lower.endsWith("fe")) { - candidates.push(term.slice(0, -2) + "VES"); + candidates.push(normalized.slice(0, -2) + "VES"); } - candidates.push(`${term}S`); + candidates.push(`${normalized}S`); if (/(s|x|z|ch|sh)$/i.test(lower)) { - candidates.push(`${term}ES`); + candidates.push(`${normalized}ES`); } return candidates.find((candidate) => entryMap.has(candidate)) || null;