Skip to content
New issue

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

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

Already on GitHub? # to your account

为分词器指定一份不同的词典不生效 #1799

Closed
1 task done
dance3366 opened this issue Jan 13, 2023 · 1 comment
Closed
1 task done

为分词器指定一份不同的词典不生效 #1799

dance3366 opened this issue Jan 13, 2023 · 1 comment
Assignees
Labels

Comments

@dance3366
Copy link

dance3366 commented Jan 13, 2023

Describe the bug
https://github.com/hankcs/HanLP/blob/1.x/src/test/java/com/hankcs/demo/DemoCustomDictionary.java
代码72行,词典指定不生效

Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.

// 每个分词器都有一份词典,默认公用 CustomDictionary.DEFAULT,你可以为任何分词器指定一份不同的词典
        DynamicCustomDictionary myDictionary = new DynamicCustomDictionary("data/dictionary/custom/CustomDictionary.txt", "data/dictionary/custom/机构名词典.txt");

Describe the current behavior
A clear and concise description of what happened.
无法指定不同的词典,源代码词典加载只加载HanLP.Config.CustomDictionaryPath配置目录下的用户词典,该方法传参未使用
image
src/main/java/com/hankcs/hanlp/dictionary/DynamicCustomDictionary.loadMainDictionary
获取本地词典更新状态也只从HanLP.Config.CustomDictionaryPath目录判断,未使用方法参数。
src/main/java/com/hankcs/hanlp/dictionary/DynamicCustomDictionary.isDicNeedUpdate
image

Expected behavior
希望指定词典可以生效

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • JDK version:1.8
  • HanLP version:portable-1.8.3

Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

  • I've completed this form and searched the web for solutions.
@hankcs
Copy link
Owner

hankcs commented Jan 13, 2023

的确只传入了第一个词典路径,其他的没有生效。

感谢反馈,已经修复,请参考上面的commit。
如果还有问题,欢迎重开issue。

@hankcs hankcs closed this as completed Jan 13, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants