(word: string)
| 172 | * that used to mint "class" → clas. |
| 173 | */ |
| 174 | export function segmentLookupVariants(word: string): string[] { |
| 175 | const variants = [word]; |
| 176 | const canStrip2 = word.length >= MIN_PROSE_CHARS + 2; |
| 177 | const canStrip1 = word.length >= MIN_PROSE_CHARS + 1; |
| 178 | if (/(?:x|sh|ss|zz)es$/.test(word)) { |
| 179 | if (canStrip2) variants.push(word.slice(0, -2)); |
| 180 | } else if (/(?:ch|s|z|o)es$/.test(word)) { |
| 181 | if (canStrip2) variants.push(word.slice(0, -2)); |
| 182 | if (canStrip1) variants.push(word.slice(0, -1)); |
| 183 | } else if (word.endsWith('s') && !word.endsWith('ss')) { |
| 184 | if (canStrip1) variants.push(word.slice(0, -1)); |
| 185 | } |
| 186 | return variants; |
| 187 | } |
no test coverage detected