Repository navigation
FIX Strip Unicode punctuation when classifying words in ContentWordSelectionStrategy - #4259
Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Conversation
…lectionStrategy ContentWordSelectionStrategy stripped only string.punctuation (ASCII) before the stopword and candidate_words checks, so quoted stopwords like “the” were selected as content words and allowlisted words wrapped in curly quotes, guillemets, ¿/¡ or an ellipsis were never selected. Fixes microsoft#4258 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Fixes #4258.
ContentWordSelectionStrategy._normalize_word()stripped punctuation withword.strip(string.punctuation), which only covers ASCII. Curly quotes, guillemets,¿/¡,…,—and CJK brackets stayed on the token, so the stopword andcandidate_wordschecks compared“the”withtheand“bomb”withbomb. Quoted stopwords were selected as content words, and allowlisted words in Unicode punctuation were never selected.SATAMaskingConverteruses this strategy by default._normalize_word()now strips leading and trailing characters that are instring.punctuationor in a Unicode punctuation category (P*). Punctuation inside a word (don’t) is kept, andcandidate_wordsgo through the same normalization as before.candidate_wordsmatch inside curly quotes, guillemets,¡…!,…,「」and。, that inner apostrophes are kept, and that punctuation-only tokens are still not content words. TwoSATAMaskingConvertertests cover the same cases end to end.Before / after for the repro in #4258:
This change was prepared with the help of Claude Code (an AI coding assistant). I reviewed the change and the tests.
🤖 Generated with Claude Code