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

Function step3

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

* Step 3: Handle various suffixes with measure > 0

(word: string)

Source from the content-addressed store, hash-verified

193 * Step 3: Handle various suffixes with measure > 0
194 */
195function step3(word: string): string {
196 const suffixes: [string, string][] = [
197 ["icate", "ic"],
198 ["ative", ""],
199 ["alize", "al"],
200 ["iciti", "ic"],
201 ["ical", "ic"],
202 ["ful", ""],
203 ["ness", ""],
204 ];
205
206 for (const [suffix, replacement] of suffixes) {
207 if (word.endsWith(suffix)) {
208 const stem = word.slice(0, -suffix.length);
209 if (hasMeasureGreaterThan0(stem)) {
210 return stem + replacement;
211 }
212 return word;
213 }
214 }
215
216 return word;
217}
218
219/**
220 * Step 4: Remove suffixes with measure > 1

Callers 1

stemFunction · 0.85

Calls 2

hasMeasureGreaterThan0Function · 0.85
endsWithMethod · 0.45

Tested by

no test coverage detected