MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / tokenizeForFts

Function tokenizeForFts

packages/node-runtime/src/nlp/fts-tokenizer.ts:13–26  ·  view source on GitHub ↗
(text: string | null | undefined)

Source from the content-addressed store, hash-verified

11import { getJieba } from './segmenter'
12
13export 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
28function fallbackTokenize(text: string): string {
29 return text

Callers 3

buildFtsIndexFunction · 0.90
insertFtsEntriesFunction · 0.90

Calls 2

getJiebaFunction · 0.90
fallbackTokenizeFunction · 0.85

Tested by

no test coverage detected