processSuffixes(word) { const maxSuffixes = word.length > 5 ? 4 : word.length - 2; for (let i = maxSuffixes; i >= 0; i -= 1) { const suffixes = StemmerHi.suffixes[i]; for (let j = 0; j < suffixes.length; j += 1) { if (word.endsWith(suffixes[j])) { return word.slice(0, -suffixes[j].length); } } } return word; }
removeSuffix(srcWord) { let word = srcWord; let removed; const syllables = this.countSyllables(word); for (let i = 0; i < StemmerTl.suffixes.length; i += 1) { const suffix = StemmerTl.suffixes[i]; if ( this.hasSuffix(word, suffix) && syllables - this.countSyllables(suffix) > 1 ) { word = word.slice(0, word.length - suffix.length); removed = suffix; break; } } if (removed && removed.length === 3 && word[word.length - 1] === 'u') { word = this.replaceAt(word, word.length - 1, 'o'); } if (removed && removed.length === 2 && word[word.length - 2] === 'u') { word = this.replaceAt(word, word.length - 2, 'o'); } if (removed && removed.length === 2 && word[word.length - 1] === 'u') { word = this.replaceAt(word, word.length - 1, 'o'); } return word; }
processSuffixes(word) { const maxSuffixes = word.length > 7 ? 6 : word.length - 2; for (let i = maxSuffixes; i >= 0; i -= 1) { const suffixes = StemmerBn.suffixes[i]; for (let j = 0; j < suffixes.length; j += 1) { if (word.endsWith(suffixes[j])) { return word.slice(0, -suffixes[j].length); } } } return word; }