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

Function step2

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

* Step 2: Handle various suffixes with measure > 0

(word: string)

Source from the content-addressed store, hash-verified

152 * Step 2: Handle various suffixes with measure > 0
153 */
154function step2(word: string): string {
155 const suffixes: [string, string][] = [
156 ["ational", "ate"],
157 ["tional", "tion"],
158 ["enci", "ence"],
159 ["anci", "ance"],
160 ["izer", "ize"],
161 ["abli", "able"],
162 ["alli", "al"],
163 ["entli", "ent"],
164 ["eli", "e"],
165 ["ousli", "ous"],
166 ["ization", "ize"],
167 ["ation", "ate"],
168 ["ator", "ate"],
169 ["alism", "al"],
170 ["iveness", "ive"],
171 ["fulness", "ful"],
172 ["ousness", "ous"],
173 ["aliti", "al"],
174 ["iviti", "ive"],
175 ["biliti", "ble"],
176 ["logi", "log"],
177 ];
178
179 for (const [suffix, replacement] of suffixes) {
180 if (word.endsWith(suffix)) {
181 const stem = word.slice(0, -suffix.length);
182 if (hasMeasureGreaterThan0(stem)) {
183 return stem + replacement;
184 }
185 return word;
186 }
187 }
188
189 return word;
190}
191
192/**
193 * Step 3: Handle various suffixes with measure > 0

Callers 1

stemFunction · 0.85

Calls 2

hasMeasureGreaterThan0Function · 0.85
endsWithMethod · 0.45

Tested by

no test coverage detected