mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-05-24 07:30:52 +08:00
feat: 话题迁移至洞察
This commit is contained in:
@@ -59,13 +59,16 @@ export function getJieba(dictType: DictType = 'default'): JiebaInstance {
|
||||
const { Jieba } = require('@node-rs/jieba')
|
||||
|
||||
const diskDict = tryLoadDictFromDisk(effectiveType)
|
||||
if (!diskDict) {
|
||||
throw new Error(`Dict file not found for: ${effectiveType}. Please ensure the dictionary has been downloaded.`)
|
||||
let instance: JiebaInstance
|
||||
if (diskDict) {
|
||||
instance = Jieba.withDict(diskDict)
|
||||
console.log(`[NLP] jieba dict loaded: ${effectiveType} (${diskDict.length} bytes)`)
|
||||
} else {
|
||||
// 词库缺失时仍保留 jieba 能力,避免 FTS 退化为空格切分。
|
||||
instance = new Jieba()
|
||||
console.warn(`[NLP] jieba dict missing: ${effectiveType}, fallback to built-in tokenizer`)
|
||||
}
|
||||
|
||||
const instance: JiebaInstance = Jieba.withDict(diskDict)
|
||||
console.log(`[NLP] jieba dict loaded: ${effectiveType} (${diskDict.length} bytes)`)
|
||||
|
||||
jiebaInstances.set(effectiveType, instance)
|
||||
return instance
|
||||
} catch (error) {
|
||||
|
||||
Vendored
+1
-1
@@ -899,7 +899,7 @@ interface NetworkApi {
|
||||
}
|
||||
|
||||
// NLP API 类型 - 自然语言处理功能
|
||||
type SupportedLocale = 'zh-CN' | 'en-US'
|
||||
type SupportedLocale = 'zh-CN' | 'en-US' | 'zh-TW' | 'ja-JP'
|
||||
|
||||
/** 词性过滤模式 */
|
||||
type PosFilterMode = 'all' | 'meaningful' | 'custom'
|
||||
|
||||
Reference in New Issue
Block a user