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:

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.
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.
输出:
[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
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.