Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

加载词典路径问题 #24

Closed
hotoo opened this issue May 14, 2015 · 2 comments
Closed

加载词典路径问题 #24

hotoo opened this issue May 14, 2015 · 2 comments

Comments

@hotoo
Copy link
Contributor

hotoo commented May 14, 2015

根据 README 中示例代码:

nodejieba.loadDict(
  "./node_modules/nodejieba/dict/jieba.dict.utf8", 
  "./node_modules/nodejieba/dict/hmm_model.utf8", 
  "./node_modules/nodejieba/dict/user.dict.utf8");

模块 A 开发时自身没有问题,但是当第三方模块依赖 A 时就会出现路径问题:

DictTrie.hpp:124 FATAL file ./node_modules/nodejieba/dict/jieba.dict.utf8 open failed.

模块 A 需要写上完整路径才行:

  nodejieba.loadDict(
      __dirname + "/../node_modules/nodejieba/dict/jieba.dict.utf8",
      __dirname + "/../node_modules/nodejieba/dict/hmm_model.utf8",
      __dirname + "/../node_modules/nodejieba/dict/user.dict.utf8");

我觉得用户是否可以不关注词典的加载?至少是不需要关注词典的绝对路径。
说实话,路径中出现 node_modules/* 什么的好别扭。

  1. 是否可以考虑默认自动加载?

  2. 或者是否可以考虑提供几个方法加载不同词典,而不是要模块 A 指定另一个模块中的文件地址。例如:

    nodejiba.loadDict(nodejieba.DEFAULT_DICT);
    // 或者:
    nodejieba.loadDefaultDict();
    
@hotoo
Copy link
Contributor Author

hotoo commented May 14, 2015

#22 可能也是相关的问题。

@yanyiwu
Copy link
Owner

yanyiwu commented May 17, 2015

这个提议非常赞,在 e6e15d3 里面实现了这个需求。
使用最新的 v0.2.12 版本就可以使用了。

@hotoo hotoo closed this as completed May 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants