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

Function step1b

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

* Step 1b: Handle -eed, -ed, -ing endings

(word: string)

Source from the content-addressed store, hash-verified

94 * Step 1b: Handle -eed, -ed, -ing endings
95 */
96function step1b(word: string): string {
97 if (word.endsWith("eed")) {
98 const stem = word.slice(0, -3);
99 if (hasMeasureGreaterThan0(stem)) {
100 return word.slice(0, -1);
101 }
102 return word;
103 }
104
105 let stem = "";
106 let suffix = "";
107
108 if (word.endsWith("ed")) {
109 stem = word.slice(0, -2);
110 suffix = "ed";
111 } else if (word.endsWith("ing")) {
112 stem = word.slice(0, -3);
113 suffix = "ing";
114 }
115
116 if (suffix && containsVowel(stem)) {
117 word = stem;
118
119 if (word.endsWith("at") || word.endsWith("bl") || word.endsWith("iz")) {
120 return word + "e";
121 }
122
123 if (endsWithDoubleConsonant(word)) {
124 const last = word[word.length - 1]!;
125 if (last !== "l" && last !== "s" && last !== "z") {
126 return word.slice(0, -1);
127 }
128 }
129
130 if (hasMeasureEqual1(word) && endsWithCVC(word)) {
131 return word + "e";
132 }
133 }
134
135 return word;
136}
137
138/**
139 * Step 1c: Handle -y endings

Callers 1

stemFunction · 0.85

Calls 6

hasMeasureGreaterThan0Function · 0.85
containsVowelFunction · 0.85
endsWithDoubleConsonantFunction · 0.85
hasMeasureEqual1Function · 0.85
endsWithCVCFunction · 0.85
endsWithMethod · 0.45

Tested by

no test coverage detected