Fix HyperscanTokenizer silently dropping citations near non-ASCII characters - #334
Open
renatodvc wants to merge 1 commit into
Open
Fix HyperscanTokenizer silently dropping citations near non-ASCII characters#334renatodvc wants to merge 1 commit into
renatodvc wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
HyperscanTokenizergets byte offsets back from hyperscan and translates them to string offsets before re-running the Python regex. When a pattern consumed only part of a multi-byte character, the reported offset landed inside that character, the translation failed, and the match was discarded with no error or log line.Reproduce it
ahocorasickreturns 170 citations,hyperscanonly 163438 U. S., at 311–312, but the bug applies to any non-ASCII character.Fix
Snap an offset that lands mid character forward to the next character boundary instead of throwing the match away. Snapping happens in the hyperscan match callback, so every offset downstream is boundary aligned by construction.