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

ViterbiSegment 自定义 CustomDictionaryForcing 时启用 enableCustomDictionaryForcing 不生效 #1712

Closed
1 task done
XhstormR opened this issue Feb 21, 2022 · 2 comments
Assignees
Labels

Comments

@XhstormR
Copy link

XhstormR commented Feb 21, 2022

Describe the bug
ViterbiSegment 使用 DynamicCustomDictionary 时,同时启用 enableCustomDictionaryForcing 不生效。

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

val dictionary = DynamicCustomDictionary()
dictionary.insert("fuck", "ZH_CN_COMMON")

val segment = ViterbiSegment()
    .enableCustomDictionaryForcing(true)
    .enableCustomDictionary(dictionary)
val text = "fucking,fuckkkkkk,fuck123"

//自定义Dictionary未生效
println(segment.seg(text))

//全局Dictionary才会生效
CustomDictionary.add("fuck")
println(segment.seg(text))

输出:
[fucking/nx, ,/w, fuckkkkkk/nx, ,/w, fuck/ZH_CN_COMMON, 123/m]
[fuck/ZH_CN_COMMON, ing/nx, ,/w, fuck/ZH_CN_COMMON, kkkkk/nx, ,/w, fuck/ZH_CN_COMMON, 123/m]

Describe the current behavior
自定义DynamicCustomDictionary不生效,使用全局的CustomDictionary才会生效。

Expected behavior
自定义DynamicCustomDictionary生效。

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):MacOS
  • Python version:
  • HanLP version: image

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 Feb 21, 2022

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

@hankcs hankcs closed this as completed Feb 21, 2022
@hanlpbot
Copy link
Collaborator

This issue has been mentioned on Butterfly Effect. There might be relevant details there:

https://bbs.hankcs.com/t/python-3-9/4780/28

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

No branches or pull requests

3 participants