MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / resolveJiebaConfigPath

Function resolveJiebaConfigPath

node/opencc.js:208–229  ·  view source on GitHub ↗
(config, jieba)

Source from the content-addressed store, hash-verified

206}
207
208function 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

Callers 1

opencc.jsFile · 0.85

Calls 3

isAbsolutePathFunction · 0.85
pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected