fix: support non-Latin text in InMemoryMemoryService search#5504
Open
weiguangli-io wants to merge 2 commits intogoogle:mainfrom
Open
fix: support non-Latin text in InMemoryMemoryService search#5504weiguangli-io wants to merge 2 commits intogoogle:mainfrom
weiguangli-io wants to merge 2 commits intogoogle:mainfrom
Conversation
Fixes google#5501. `_extract_words_lower` used `[A-Za-z]+` regex which only matched ASCII letters, silently discarding Japanese, Chinese, Korean, Cyrillic and other non-Latin characters. Change to `\w+` with `re.UNICODE` to match all Unicode word characters.
Collaborator
|
Response from ADK Triaging Agent Hello @weiguangli-io, thank you for your contribution! Could you please add a You can find more information about the testing requirements in our contribution guidelines. Thanks! |
Collaborator
|
Hi @weiguangli-io , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share. |
Collaborator
|
Hi @sasha-gitg , can you please review this. |
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.
Fixes #5501
Root Cause
_extract_words_lowerusesre.findall(r'[A-Za-z]+', text)which only matches ASCII letters. All non-Latin characters (Japanese, Chinese, Korean, Cyrillic, etc.) are silently discarded, makingsearch_memoryunable to match any non-Latin text.Fix
Change the regex from
[A-Za-z]+to\w+withre.UNICODEflag, which matches all Unicode word characters (letters, digits, underscore) across all scripts.