Skip to content

feat: add Support for acronym matching and others.#569

Merged
BLumia merged 1 commit into
linuxdeepin:masterfrom
wjyrich:feat-addSearch-1
Jun 4, 2025
Merged

feat: add Support for acronym matching and others.#569
BLumia merged 1 commit into
linuxdeepin:masterfrom
wjyrich:feat-addSearch-1

Conversation

@wjyrich
Copy link
Copy Markdown
Contributor

@wjyrich wjyrich commented May 22, 2025

add Support for acronym matching,
add Intermediate matching is not supported for lowercase letters.

Log:

Summary by Sourcery

Refine the search filter logic to support acronym-based lookups, enforce prefix matching for lowercase names, and handle numeric-only display names separately while retaining existing matching behavior for other cases.

New Features:

  • Add acronym matching by extracting initials of displayName words

Enhancements:

  • Restrict substring matching to prefix-only for lowercase-only names
  • Special-case numeric names to only match leading digits
  • Preserve legacy substring matching for mixed-case or non-English display names

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 22, 2025

Reviewer's Guide

Enhanced filterAcceptsRow to support acronym matching via uppercase initials, numeric-prefix matching, and restricted startsWith matching for pure lowercase English names while preserving existing fuzzy search across name variants.

File-Level Changes

Change Details Files
Introduced acronym matching based on uppercase initials
  • Split displayName into words
  • Built lowercase first-letter acronym string
  • Included acronym in matching conditions
src/models/searchfilterproxymodel.cpp
Added numeric-prefix matching for names containing numbers
  • Used QRegularExpression to find number sequences
  • Matched numeric prefix against search pattern
  • Short-circuited match when prefix matches
src/models/searchfilterproxymodel.cpp
Restricted matching to prefix (startsWith) for pure lowercase English names
  • Detected pure-English lowercase names via regex
  • Applied startsWith matching on all fields and acronym
src/models/searchfilterproxymodel.cpp
Retained and extended default fuzzy matching logic
  • Kept contains-based matching on displayName, nameCopy, transliterated, jianpin
  • Appended acronym contains matching
src/models/searchfilterproxymodel.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @wjyrich - I've reviewed your changes - here's some feedback:

  • The numeric-matching block only checks digits in displayName but ignores other name variants (nameCopy, transliterated, jianpin); consider extending number-prefix logic to all fields for consistency.
  • Acronym logic only captures uppercase initials—if you want to support lowercase or mixed-case acronyms, adjust the word[0].isUpper() check or normalize all initials.
  • There’s a lot of repeated startsWith/contains logic between the English-only and fallback branches; extract a helper function to dedupe and clarify the matching rules.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@wjyrich wjyrich force-pushed the feat-addSearch-1 branch from dafb137 to 5321ac9 Compare May 22, 2025 07:15
Comment thread src/models/searchfilterproxymodel.cpp Outdated
@wjyrich wjyrich force-pushed the feat-addSearch-1 branch 2 times, most recently from 490d7ab to d27284c Compare May 23, 2025 07:00
Comment thread src/models/searchfilterproxymodel.cpp Outdated
@wjyrich wjyrich force-pushed the feat-addSearch-1 branch 2 times, most recently from a7ef785 to 72ae48f Compare May 23, 2025 07:41
18202781743
18202781743 previously approved these changes May 23, 2025
add Support for acronym matching,
add Intermediate matching is not supported for lowercase letters.

Log:
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

代码审查意见:

  1. 代码重复:在处理英文前缀匹配时,对 displayNamenameCopytransliteratedjianpin 的前缀匹配检查代码重复,可以考虑提取成一个函数来减少代码重复。

  2. 正则表达式匹配:在 isNumberSearchisEnglishSearch 的匹配中,searchPatternDelBlank 用于 isNumberSearch,而 searchPattern.pattern() 用于 isEnglishSearch,这可能会导致逻辑错误。应该确保 searchPatternDelBlanksearchPattern.pattern() 的使用是一致的。

  3. 性能优化:在处理英文前缀匹配时,对每个单词进行 startsWith 检查可能会影响性能,特别是当 displayNamenametransliterated 等字符串很长时。可以考虑使用更高效的数据结构或算法来优化这部分逻辑。

  4. 变量命名:变量 nameFirstLetters 可能不够直观,建议使用更具描述性的变量名,比如 initialsOfWordsfirstLettersOfWords

  5. 逻辑清晰性:在处理英文前缀匹配的逻辑中,代码结构较为复杂,建议添加注释来解释每个步骤的目的,以提高代码的可读性和可维护性。

  6. 空字符串检查:在处理英文前缀匹配时,对 displayNamenametransliterated 等字符串进行 startsWith 检查前,应该确保这些字符串不是空字符串,以避免不必要的检查。

  7. 代码风格:代码中存在一些风格不一致的地方,比如在 if 语句中,有时使用大括号,有时不使用。建议统一代码风格,以提高代码的可读性。

  8. 错误处理:在处理正则表达式匹配时,没有对可能的异常情况进行处理。建议添加错误处理逻辑,以防止因正则表达式错误导致的程序崩溃。

  9. 代码注释:代码中缺少对新增逻辑的注释说明,建议添加注释来解释新增代码的目的和作用。

  10. 代码测试:建议编写单元测试来验证新增逻辑的正确性和性能,以确保代码的质量和可靠性。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, wjyrich

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@BLumia BLumia merged commit 3e70141 into linuxdeepin:master Jun 4, 2025
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants