* Step 4: Remove suffixes with measure > 1
(word: string)
| 220 | * Step 4: Remove suffixes with measure > 1 |
| 221 | */ |
| 222 | function step4(word: string): string { |
| 223 | const suffixes = [ |
| 224 | "al", |
| 225 | "ance", |
| 226 | "ence", |
| 227 | "er", |
| 228 | "ic", |
| 229 | "able", |
| 230 | "ible", |
| 231 | "ant", |
| 232 | "ement", |
| 233 | "ment", |
| 234 | "ent", |
| 235 | "ion", |
| 236 | "ou", |
| 237 | "ism", |
| 238 | "ate", |
| 239 | "iti", |
| 240 | "ous", |
| 241 | "ive", |
| 242 | "ize", |
| 243 | ]; |
| 244 | |
| 245 | for (const suffix of suffixes) { |
| 246 | if (word.endsWith(suffix)) { |
| 247 | const stem = word.slice(0, -suffix.length); |
| 248 | if (suffix === "ion") { |
| 249 | if (hasMeasureGreaterThan1(stem) && (stem.endsWith("s") || stem.endsWith("t"))) { |
| 250 | return stem; |
| 251 | } |
| 252 | } else if (hasMeasureGreaterThan1(stem)) { |
| 253 | return stem; |
| 254 | } |
| 255 | return word; |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | return word; |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * Step 5a: Remove trailing 'e' if measure > 1, |
no test coverage detected