(dictId: string)
| 44 | } |
| 45 | |
| 46 | function tryLoadDictFromDisk(dictId: string): Buffer | null { |
| 47 | if (!_nlpDir) return null |
| 48 | const dictPath = path.join(_nlpDir, `${dictId}.dict`) |
| 49 | if (!fs.existsSync(dictPath)) return null |
| 50 | try { |
| 51 | return fs.readFileSync(dictPath) |
| 52 | } catch { |
| 53 | return null |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * 获取 Jieba 实例(支持多词库) |