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

Function deleteDict

packages/node-runtime/src/nlp/dict-manager.ts:137–150  ·  view source on GitHub ↗
(nlpDir: string, dictId: string)

Source from the content-addressed store, hash-verified

135}
136
137export function deleteDict(nlpDir: string, dictId: string): { success: boolean; error?: string } {
138 const filePath = getDictFilePath(nlpDir, dictId)
139 if (!fs.existsSync(filePath)) return { success: true }
140 try {
141 fs.unlinkSync(filePath)
142 clearJiebaInstance(dictId as any)
143 console.log(`[NLP DictManager] Dict deleted: ${dictId}`)
144 return { success: true }
145 } catch (error) {
146 const msg = error instanceof Error ? error.message : String(error)
147 console.error(`[NLP DictManager] Delete failed for ${dictId}:`, msg)
148 return { success: false, error: msg }
149 }
150}
151
152/**
153 * 自动下载默认词库(应用启动时调用)

Callers 1

registerNlpRoutesFunction · 0.90

Calls 3

clearJiebaInstanceFunction · 0.90
getDictFilePathFunction · 0.85
errorMethod · 0.65

Tested by

no test coverage detected