Skip to content

fix: adjust order of time recognition patterns#353

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
Johnson-zs:master
Jul 16, 2026
Merged

fix: adjust order of time recognition patterns#353
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
Johnson-zs:master

Conversation

@Johnson-zs

@Johnson-zs Johnson-zs commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Modified the pattern order in Chinese time recognition rules to improve
matching efficiency. Changed from "今天|今日|今日份" to "今天|今日份|
今日" based on usage frequency analysis showing "今天" is more commonly
used than "今日份" in queries.

fix:调整时间识别模式的顺序

修改了中文时间识别规则中的模式顺序以提高匹配效率。基于使用频率分析,将
模式从"今天|今日|今日份"改为"今天|今日份|今日",因为查询中"今天"比"今日
份"更常用。

Fixes: #370315

Summary by Sourcery

Bug Fixes:

  • Optimize the ordering of Chinese time patterns so common expressions like "今天" are matched more reliably in queries.

Modified the pattern order in Chinese time recognition rules to improve
matching efficiency. Changed from "今天|今日|今日份" to "今天|今日份|
今日" based on usage frequency analysis showing "今天" is more commonly
used than "今日份" in queries.

fix:调整时间识别模式的顺序

修改了中文时间识别规则中的模式顺序以提高匹配效率。基于使用频率分析,将
模式从"今天|今日|今日份"改为"今天|今日份|今日",因为查询中"今天"比"今日
份"更常用。

Fixes: #370315
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Johnson-zs

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

@sourcery-ai

sourcery-ai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR adjusts the order of Chinese time recognition patterns in the semantic rules to prioritize more frequently used expressions and improve matching efficiency for queries like "今天".

File-Level Changes

Change Details Files
Reordered Chinese time recognition patterns to prioritize more common phrases for time-related queries.
  • Updated the time recognition pattern sequence from "今天
今日

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码修复了正则表达式多选分支的匹配顺序问题,确保长词优先匹配。
逻辑完全正确,解决了语义截断缺陷,且无安全风险。

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

time_rules.json 文件的 time_today 规则中,将 pattern 字段从 "今天|今日|今日份" 修改为 "今天|今日份|今日"。正则表达式引擎在处理多选分支时通常从左至右进行匹配,原逻辑会导致输入"今日份"时被截断匹配为"今日"。修改后将长词"今日份"置于"今日"之前,确保了完整语义的正确识别。
潜在问题:无
建议:无

  • 2.代码质量(优秀)✓

修改精准且最小化,未破坏原有 JSON 结构,符合正则表达式编写的最佳实践。
潜在问题:无
建议:无

  • 3.代码性能(无性能问题)✓

调整正则分支顺序对性能无负面影响,反而可能略微减少匹配失败时的回溯次数。
潜在问题:无
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次修改仅为 JSON 配置文件中的正则字符串调整,不涉及任何外部输入解析、命令执行或内存操作,不存在攻击面。

  • 建议:无

■ 【改进建议代码示例】

diff --git a/src/dfm-search/dfm-search-lib/semantic/rules/zh_CN/time_rules.json b/src/dfm-search/dfm-search-lib/semantic/rules/zh_CN/time_rules.json
index 20f116e..c145c78 100644
--- a/src/dfm-search/dfm-search-lib/semantic/rules/zh_CN/time_rules.json
+++ b/src/dfm-search/dfm-search-lib/semantic/rules/zh_CN/time_rules.json
@@ -8,7 +8,7 @@
             "rules": [
                 {
                     "id": "time_today",
-                    "pattern": "今天|今日|今日份",
+                    "pattern": "今天|今日份|今日",
                     "description": "Today",
                     "enabled": true,
                     "priority": 200,

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


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.

@Johnson-zs

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit f57c406 into linuxdeepin:master Jul 16, 2026
21 of 23 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.

2 participants