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

The CangjieTokenStream index is wrong #20

Closed
WincerChan opened this issue Feb 18, 2021 · 2 comments
Closed

The CangjieTokenStream index is wrong #20

WincerChan opened this issue Feb 18, 2021 · 2 comments

Comments

@WincerChan
Copy link
Contributor

The problem is that when I want to create a snippet of tantivy query result, an error(byte index xx is out of bounds of xxxx) will be raised. Looks like an out-of-bounds access to the string(byte array).

This is my test code: https://gist.github.com/WincerChan/09a1777944914164f6a22b62c95ec564

cargo dependencies:

  1. tantivy = "0.14.0"
  2. cang-jie = "0.11.0"
  3. jieba-rs = { version = "0.6.2", default-features = false }

After some works, I find the problem is token stream: https://github.com/DCjanus/cang-jie/blob/master/src/stream.rs#L30

The variable offset_from does not start from 0, but from current_word.len(), So there will be an out-of-bounds error at the last token.

If necessary, I can make a PR to fix it.

@DCjanus
Copy link
Owner

DCjanus commented Feb 19, 2021

Thanks for your report, I'd like to fix this in a while, PR is welcome.

@WincerChan
Copy link
Contributor Author

WincerChan commented Feb 19, 2021

@DCjanus You are welcome. PR: #21

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

No branches or pull requests

2 participants