MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / segmentEnglish

Function segmentEnglish

packages/node-runtime/src/nlp/segmenter.ts:120–132  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

118}
119
120function segmentEnglish(text: string): string[] {
121 const cleaned = cleanText(text)
122 if (!cleaned) return []
123 try {
124 const segmenter = new Intl.Segmenter('en', { granularity: 'word' })
125 return [...segmenter.segment(cleaned)].filter((s) => s.isWordLike).map((s) => s.segment.toLowerCase())
126 } catch {
127 return cleaned
128 .toLowerCase()
129 .split(/\s+/)
130 .filter((w) => w.length > 0)
131 }
132}
133
134function segmentJapanese(text: string): string[] {
135 const cleaned = cleanText(text)

Callers 1

segmentFunction · 0.85

Calls 1

cleanTextFunction · 0.90

Tested by

no test coverage detected