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

[feature](analysis) add new chinese tokenizer IK #269

Open
wants to merge 2 commits into
base: clucene
Choose a base branch
from

Conversation

Ryan19929
Copy link

Support IK tokenizer for inverted index:
Migrate analysis-ik from Java to C++, Implement basic tokenization functionality.
The major differences from the original Java code are as follows:

  1. Encoding Format Difference: Use /jieba/Unicode.hpp to process characters in IK-C++.
  2. Memory Management Optimization: Add a custom allocator to avoid performance overhead caused by frequent memory allocation in STL containers.
  3. Remote Dictionary Support: IK-C++ does not currently support remote dictionaries.

Major changes to the original code:

  1. testChinese.cpp: Add test for testing Chinese tokenization speed. Use the dataset located at /src/test/data/contribs-lib/analysis/chinese/speed-test-text.txt (红楼梦) for testing.
  2. LanguageBasedAnalyzer.h/cpp:
    Add IK tokenizer configuration, initialization entry, and dictionary loading logic.
    Add the IK tokenization mode entry (temporary mode entry) in AnalyzerMode.


CL_NS_DEF(analysis)

enum class AnalyzerMode {
Default,
All,
Search
Search,
IK_Smart,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest separating the IK and Jieba enums for better clarity.

if (store_size_ >= children_array_.size()) {
children_array_.resize(store_size_ + 1);
}
// 插入并保持有序
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest using English comments.

@Ryan19929 Ryan19929 force-pushed the clucene-ik-20250102 branch 3 times, most recently from f538355 to e45e3f3 Compare January 20, 2025 05:46
Copy link
Collaborator

@zzzxl1993 zzzxl1993 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Migrate analysis-ik from Java to C++, implement basic tokenization functionality, and integrate it into CLucene.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants