(word: string)
| 17 | */ |
| 18 | const SUFFIXES = ['ation', 'ising', 'izing', 'ings', 'ing', 'ers', 'ies', 'er', 'ed', 'es', 'ate', 'ly', 's']; |
| 19 | export function stem(word: string): string { |
| 20 | if (word.length <= 4) return word; |
| 21 | for (const suf of SUFFIXES) { |
| 22 | if (word.endsWith(suf) && word.length - suf.length >= 3) { |
| 23 | let root = word.slice(0, word.length - suf.length); |
| 24 | if (suf === 'ies') root += 'y'; // categories → category |
| 25 | return root; |
| 26 | } |
| 27 | } |
| 28 | return word; |
| 29 | } |
| 30 | |
| 31 | /** Tokenize + stem — the recall ranker's semantic-lexical vocabulary. PURE. */ |
| 32 | export function semanticTokens(text: string): string[] { |
no outgoing calls
no test coverage detected