Skip to content

Double pinyin query #2427

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

Draft
wants to merge 22 commits into
base: dev
Choose a base branch
from
Draft

Double pinyin query #2427

wants to merge 22 commits into from

Conversation

VictoriousRaptor
Copy link
Contributor

No description provided.

This comment has been minimized.

This comment has been minimized.

@VictoriousRaptor VictoriousRaptor marked this pull request as draft November 19, 2023 03:48

This comment has been minimized.

This comment has been minimized.

{"ian", "m"}
});

private static string ToDoublePin(string fullPinyin)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to use ReadOnlySpan as we have quite a few slicing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@taooceros
Copy link
Member

@VictoriousRaptor what's the status of this pr?

@VictoriousRaptor
Copy link
Contributor Author

@VictoriousRaptor what's the status of this pr?

POC. I'm using it daily and so far so good. Since there're many double pinyin mappings we should make it user configurable. Is it acceptable to allow users to edit a json file that defines the mapping?

@taooceros
Copy link
Member

well I can't think anything better...maybe I do want this to be plugin-able, but can't think of a good way to design the api.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@Jack251970 Jack251970 requested a review from Copilot April 9, 2025 01:43
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

Flow.Launcher.Infrastructure/UserSettings/Settings.cs:240

  • [nitpick] The inline comment 'For developing' is vague. Consider clarifying whether UseDoublePinyin is intended for development only or should be enabled in production.
public bool UseDoublePinyin { get; set; } = true; //For developing

Flow.Launcher.Infrastructure/StringMatcher.cs:71

  • The condition has been inverted compared to the original usage of !CanBeTranslated. Please verify that using ShouldTranslate(query) yields the intended translation logic.
if (_alphabet is not null && _alphabet.ShouldTranslate(query))

@Jack251970 Jack251970 requested a review from Copilot April 9, 2025 11:41
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

Flow.Launcher.Infrastructure/PinyinAlphabet.cs:64

  • [nitpick] Consider renaming the variable 'dp' to a more descriptive name like 'doublePinyin' for clarity.
string dp = _settings.UseDoublePinyin ? ToDoublePin(resultList[i]) : resultList[i];

This comment has been minimized.

This comment has been minimized.

@Jack251970 Jack251970 requested a review from Copilot April 9, 2025 12:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

Flow.Launcher.Infrastructure/UserSettings/Settings.cs:240

  • [nitpick] The inline comment '//For developing' is ambiguous; consider clarifying or removing it if the flag is intended for production use.
public bool UseDoublePinyin { get; set; } = true; //For developing

Flow.Launcher.Infrastructure/StringMatcher.cs:71

  • The condition has been changed from negating CanBeTranslated to using ShouldTranslate directly; please verify that the new logic correctly reflects the intended translation behavior.
if (_alphabet is not null && _alphabet.ShouldTranslate(query))

This comment has been minimized.

This comment has been minimized.

@Jack251970 Jack251970 requested a review from Copilot April 10, 2025 01:58
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

Flow.Launcher.Infrastructure/UserSettings/Settings.cs:240

  • [nitpick] Consider updating or removing the 'For developing' comment if this setting is expected to be part of production to avoid confusion.
public bool UseDoublePinyin { get; set; } = true; //For developing

Flow.Launcher.Infrastructure/PinyinAlphabet.cs:165

  • When fullPinyin.Length is >= 2 but the first two characters do not match any key in the 'first' dictionary, no conversion is applied, which may result in an empty result. Consider adding a fallback to handle cases when the initial conversion is not matched.
if (fullPinyin.Length >= 2)

Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors Count
❌ forbidden-pattern 22
⚠️ non-alpha-in-dictionary 19

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants