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

reload热更新问题 #1136

Closed
1 task done
CCMBChina opened this issue Mar 28, 2019 · 3 comments
Closed
1 task done

reload热更新问题 #1136

CCMBChina opened this issue Mar 28, 2019 · 3 comments

Comments

@CCMBChina
Copy link

注意事项

请确认下列注意事项:

  • 我已仔细阅读下列文档,都没有找到答案:
  • 我已经通过Googleissue区检索功能搜索了我的问题,也没有找到答案。
  • 我明白开源社区是出于兴趣爱好聚集起来的自由社区,不承担任何责任或义务。我会礼貌发言,向每一个帮助我的人表示感谢。
  • 我在此括号内输入x打钩,代表上述事项确认完毕。

版本号

当前最新版本号是:1.7.2
我使用的版本是:1.7.2

我的问题

需要实现载入内存后字典的更新
想达到效果如修改txt词典增加词语后,jar能重新载入
发现提供了CustomDictionary.reload,故使用此api过程中产生了与预期不一致的分词情况

复现问题

步骤

  1. 首先在dictionary下新增自定义词典menu.txt,其中有词盒饭 日料,运行如下代码
  2. 然后在线程sleep时往词典中新增 真好吃

触发代码

    public void testIssue1234() throws Exception
    {
         String text = "盒饭日料真好吃";
         System.out.println(StandardTokenizer.segment(text ));
          Thread.sleep(60000); //此时在新增的词典menu.txt中加入 <真好吃>
         CustomDictionary.reload();
        System.out.println(StandardTokenizer.segment(text));
    }

期望输出

期望第一次输出:<盒饭> <日料> <真> <好吃>
期望第二次输出:<盒饭> <日料> <真好吃>
期望输出


### 实际输出

第一次输出:<盒饭> <日料> <真> <好吃>
第二次输出:<盒饭> <日料> <真> <好吃>

reload并没有更新各个分词器中dat原有数据内容 ,仅更新了 CustomDictionary中自有的dat

实际输出


## 其他信息

<!-- 任何可能有用的信息,包括截图、日志、配置文件、相关issue等等。-->

@hankcs
Copy link
Owner

hankcs commented Mar 29, 2019

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

@CCMBChina
Copy link
Author

@hankcs 感谢 请问什么时候合到1.7.2 或者1.7.3

@hankcs
Copy link
Owner

hankcs commented Mar 30, 2019

没有固定的计划,建议自行编译。

huminghe pushed a commit to huminghe/HanLP that referenced this issue Apr 23, 2019
hankcs added a commit that referenced this issue Jan 10, 2020
Montinosq added a commit to Montinosq/HanLP that referenced this issue Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants