Describe the feature and the current behavior/state.
|
int pos = Math.max(siblings.get(0).code + 1, nextCheckPos) - 1; |
int pos = Math.max(siblings.get(0).code + 1, nextCheckPos) - 1;
改成
int pos = Math.max(siblings.get(0).code, nextCheckPos);
构建速度可以提升很多而且表现稳定,缺点是最终构建出的DAT大小微增。下面是我的测试数据:

其中保留nextCheckPos为原版代码,去掉nextCheckPos用作对比,核心循环计数是在循环体内做了一个count++计数:

Will this change the current api? How?
No
Who will benefit with this feature?
Anyone who uses DAT
Are you willing to contribute it (Yes/No):
Yes
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS Big Sur
- Python version:
- HanLP version: hanlp-portable-1.8.3.jar
Any other info
Describe the feature and the current behavior/state.
HanLP/src/main/java/com/hankcs/hanlp/collection/trie/DoubleArrayTrie.java
Line 167 in 1323221
int pos = Math.max(siblings.get(0).code + 1, nextCheckPos) - 1;改成
int pos = Math.max(siblings.get(0).code, nextCheckPos);构建速度可以提升很多而且表现稳定,缺点是最终构建出的DAT大小微增。下面是我的测试数据:
其中保留nextCheckPos为原版代码,去掉nextCheckPos用作对比,核心循环计数是在循环体内做了一个

count++计数:Will this change the current api? How?
No
Who will benefit with this feature?
Anyone who uses DAT
Are you willing to contribute it (Yes/No):
Yes
System information
Any other info