(config, jieba)
| 206 | } |
| 207 | |
| 208 | function resolveJiebaConfigPath(config, jieba) { |
| 209 | if (!jieba || isAbsolutePath(config)) { |
| 210 | return null; |
| 211 | } |
| 212 | if (typeof jieba.resolveConfigPath === 'function') { |
| 213 | return jieba.resolveConfigPath(config); |
| 214 | } |
| 215 | const candidates = [config]; |
| 216 | if (!config.endsWith('.json')) { |
| 217 | candidates.push(config + '.json'); |
| 218 | } |
| 219 | for (const candidate of candidates) { |
| 220 | if (candidate.includes('/') || candidate.includes('\\')) { |
| 221 | continue; |
| 222 | } |
| 223 | const configPath = path.join(jieba.dataDir, candidate); |
| 224 | if (fs.existsSync(configPath)) { |
| 225 | return configPath; |
| 226 | } |
| 227 | } |
| 228 | return null; |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * OpenCC Node.js API |
no test coverage detected