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

HanLP 1.x 加载 bin 的错误 #1594

Closed
1 task done
zhuyuanxiang opened this issue Dec 21, 2020 · 2 comments
Closed
1 task done

HanLP 1.x 加载 bin 的错误 #1594

zhuyuanxiang opened this issue Dec 21, 2020 · 2 comments
Assignees
Labels

Comments

@zhuyuanxiang
Copy link

Describe the bug
连续加载两次模型时,第二次没有加载而是直接使用第一次加载的模型

Code to reproduce the issue

    public static void main(String[] args) {
        // 第一次执行会报出警告,然后会转换 txt 文件为 bin 文件,后面就不再报错
        // 连续执行两次时,第二次使用的是第一次载入的 bin 文件
        // 交换以下现场代码的顺序就可以看到区别
        show_subtitle("my_cws_model");
        trainBigram(MY_CWS_CORPUS_PATH, MY_MODEL_PATH);
        loadBigram(MY_MODEL_PATH);
        show_subtitle("msr_ngram");
        trainBigram(MSR_TRAIN_PATH, MSR_MODEL_PATH);
        loadBigram(MSR_MODEL_PATH);
    }

详情可以参考:https://github.com/zhuyuanxiang/Hanlp-Books-Examples/blob/main/src/main/java/ch03/sec03/DemoNgramSegment.java

Describe the current behavior
--------------->my_cws_model<---------------
「商品」的词频:2
「商品@和」的频次:1
[商品, 和, 服务]
[货币, 和, 服务]
--------------->msr_ngram<---------------
「商品」的词频:2
「商品@和」的频次:1
[商品, 和, 服务]
[货币, 和, 服务]

Expected behavior
--------------->my_cws_model<---------------
「商品」的词频:2
「商品@和」的频次:1
[商品, 和, 服务]
[货币, 和, 服务]
--------------->msr_ngram<---------------
「商品」的词频:1
「商品@和」的频次:0
[商品, 和, 服务]
[货币, 和, 服务]

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
  • Python version:
  • Java version: 8.0
  • HanLP version: 1.7.8

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 Dec 22, 2020

感谢反馈。这个演示的本意是让用户注释掉一个运行另一个的,如果要让程序同时运行两个,得参考上面新加的reload方法。

@hankcs hankcs closed this as completed Dec 22, 2020
@zhuyuanxiang
Copy link
Author

OK.
thks!
感谢你的及时反馈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants