(nlpDir: string)
| 31 | } |
| 32 | |
| 33 | export function getDictList(nlpDir: string): DictInfo[] { |
| 34 | return AVAILABLE_DICTS.map((d) => { |
| 35 | const filePath = getDictFilePath(nlpDir, d.id) |
| 36 | const downloaded = fs.existsSync(filePath) |
| 37 | let fileSize: number | undefined |
| 38 | if (downloaded) { |
| 39 | try { |
| 40 | fileSize = fs.statSync(filePath).size |
| 41 | } catch { |
| 42 | /* ignore */ |
| 43 | } |
| 44 | } |
| 45 | return { ...d, downloaded, fileSize } |
| 46 | }) |
| 47 | } |
| 48 | |
| 49 | export function loadDictBuffer(nlpDir: string, dictId: string): Buffer | null { |
| 50 | const filePath = getDictFilePath(nlpDir, dictId) |
no test coverage detected