Skip to content

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

@dance3366

Description

@dance3366

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.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions