MCPcopy Create free account
hub / github.com/codemix/graph / step4

Function step4

packages/text-search/src/stemmer.ts:222–260  ·  view source on GitHub ↗

* Step 4: Remove suffixes with measure > 1

(word: string)

Source from the content-addressed store, hash-verified

220 * Step 4: Remove suffixes with measure > 1
221 */
222function 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,

Callers 1

stemFunction · 0.85

Calls 2

hasMeasureGreaterThan1Function · 0.85
endsWithMethod · 0.45

Tested by

no test coverage detected