(nlpDir: string, dictId: string)
| 135 | } |
| 136 | |
| 137 | export 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 | * 自动下载默认词库(应用启动时调用) |
no test coverage detected