(text: string | null | undefined)
| 11 | import { getJieba } from './segmenter' |
| 12 | |
| 13 | export function tokenizeForFts(text: string | null | undefined): string { |
| 14 | if (!text || text.trim().length === 0) return '' |
| 15 | |
| 16 | try { |
| 17 | const jieba = getJieba() |
| 18 | const tokens = jieba.cut(text, false) |
| 19 | return tokens |
| 20 | .map((t) => t.trim().toLowerCase()) |
| 21 | .filter((t) => t.length > 0) |
| 22 | .join(' ') |
| 23 | } catch { |
| 24 | return fallbackTokenize(text) |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | function fallbackTokenize(text: string): string { |
| 29 | return text |
no test coverage detected