-
Notifications
You must be signed in to change notification settings - Fork 7.2k
feat(cmdpal): add pinyin support for Chinese input method #39354
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
base: main
Are you sure you want to change the base?
Conversation
@frg2089 What is the reason for using a different Pinyin package than we already use for PT Run (hyjiacan.pinyin4net)? I think we should avoid using different pinyin packages. What do you think @zadjii-msft? |
@zadjii-msft |
I just selected a recently updated package on nuget according to the last update time. The last update time of hyjiacan.pinyin4net was 2022/2/23. Please let me know if you want me to continue using hyjiacan.pinyin4net. |
one question, does this package support Native AOT? if not, we can't get it in. |
I build it with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for matching Chinese text by converting inputs and targets to their pinyin representations before performing fuzzy matching.
- Introduces the ToolGood.Words.Pinyin package as a dependency.
- Extends
StringMatcher.FuzzyMatch
to generate and match pinyin variants. - Updates central package versions in
Directory.Packages.props
.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/StringMatcher.cs | Implement pinyin generation and matching loop |
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Microsoft.CommandPalette.Extensions.Toolkit.csproj | Add ToolGood.Words.Pinyin package reference |
Directory.Packages.props | Pin ToolGood.Words.Pinyin version centrally |
Comments suppressed due to low confidence (1)
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/StringMatcher.cs:82
- New pinyin matching behavior isn't covered by existing tests. Add unit tests for Chinese inputs and their pinyin variants to validate correctness.
queryList.Add(WordsHelper.GetPinyin(input));
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/StringMatcher.cs
Outdated
Show resolved
Hide resolved
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/StringMatcher.cs
Outdated
Show resolved
Hide resolved
List<string> stringToCompareList = [stringToCompare]; | ||
|
||
// TODO: Add switch for Chinese. | ||
if (true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Avoid using if (true)
as a placeholder. Replace with a real feature flag or user-setting check to toggle pinyin support.
if (true) | |
if (EnablePinyinSupport) |
Copilot uses AI. Check for mistakes.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@cinnamon-msft, in this PR, there are multiple input need and see if you have any suggestion/objection:
|
This comment has been minimized.
This comment has been minimized.
It's easy to add a new setting to control this behaviour. See this PR as sample: https://github.com/microsoft/PowerToys/pull/38923/files#diff-2550e476d6684aaba319126262868c92cceb2d9776d3d78348baf4167824b30c Ok, I've verified this PR is AOT compatible. |
I have created settings for Pinyin support, but I don't know how to make StringMatcher use it. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Could you please merge main into your branch? |
- Add ToolGood.Words.Pinyin package to support pinyin conversion - Implement pinyin matching in StringMatcher class - Update project dependencies and Directory.Packages.props Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
- Added notice for the use of ToolGood.Words.Pinyin NuGet package - Included MIT License information for ToolGood.Words.Pinyin - Updated NOTICE.md to reflect the new dependency Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
…sions.Toolkit/StringMatcher.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Upgraded ToolGood.Words.Pinyin package from version 3.1.0.2 to 3.1.0.3 Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
- Add EnableChinesePinYinSupport setting to SettingsModel - Implement EnableChinesePinYinSupport property in SettingsViewModel - Create UI toggle for EnableChinesePinYinSupport in GeneralPage.xaml - Add localization strings for new Chinese PinYin support setting Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
- Rename "Enable Chinese PinYin Support" to "PinYin Support for Chinese" - Update description from "Allows searching for Chinese characters using PinYin" to "Search Chinese contents with PinYin" thanks @sovetskyfish Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
56696b4
to
e6c6bb8
Compare
This comment has been minimized.
This comment has been minimized.
Could you please fix spellcheck issue? see: https://github.com/microsoft/PowerToys/blob/main/.github/actions/spell-check/expect.txt Or grant the permission to me and I can help to fix this issue. |
- Add 'toolgood' to the list of expected words - Maintain existing entries and order Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Pipeline failed. Could you please add the pinyin package name to Notice.md? MissingFromNotice:
|
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@moooyo |
ci passed |
Oh...I missed. Sure, it's hard to use settings in toolkit. We need to find a way. Maybe add a config parameter is a good idea? |
We need to design it carefully, because it was used in so many case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this PR it self, I like this idea and this implement.
But we still need to find a proper way to use it in StringMatcher.
Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
I've completed a rough implementation of pinyin support, but since I'm currently unsure where to add the toggle for pinyin support, this feature is enabled by default for now.
2025-05-11.230855.mp4
Validation Steps Performed