fix(dfm-search): support Chinese-numeral years in semantic time parsing - #373
Conversation
The year capture group in time rules only matched Arabic numerals
(\d{2,4}), so queries like "二五年十二月创建的表格" failed to recognise
the year. The month fell back to the current-year rule and the
unconsumed "二五年" leaked into keywords, producing empty results.
- time_rules.json: extend year group to \d{2,4}|[零〇一二三四五六七八九]{2,4}
for time_exact_year, time_exact_year_month, time_exact_full_date;
add "〇":0 to their digit_map.
- timeextractor.cpp: add digit-by-digit Chinese numeral parsing in
localeAwareToInt (e.g. "二五"→25, "二零二五"→2025).
- tst_chinese_nlp.cpp: add regression tests for Chinese-numeral year
queries and verify no residual keyword leak.
Log: 修复中文数字年份叠加搜索结果为空的问题
PMS: BUG-372165
Influence: 语义搜索现在能正确识别"二五年"/"二零二五年"等中文数字年份,不再将其泄露为关键词或误绑到当前年份。
There was a problem hiding this comment.
Sorry @Johnson-zs, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideThis PR fixes dfm-search semantic time parsing so that Chinese-numeral years (e.g. “二五年”, “二零二五年”, “二〇二五年”) are correctly recognised by year/year-month/full-date rules, parsed into proper year values, and fully consumed without leaking into residual keywords, while preserving existing month-only and “十”-style numeral behaviour. Sequence diagram for Chinese-numeral year parsing in dfm-search semantic time extractionsequenceDiagram
actor User
participant SemanticSearch
participant TimeRules
participant TimeExtractor
participant KeywordExtractor
User->>SemanticSearch: search("二五年十二月创建的表格")
SemanticSearch->>TimeRules: apply time_exact_year_month
TimeRules-->>SemanticSearch: match year="二五" month="十二"
SemanticSearch->>TimeExtractor: localeAwareToInt("二五", digitMap)
TimeExtractor-->>SemanticSearch: 2025
SemanticSearch->>TimeExtractor: localeAwareToInt("十二", digitMap)
TimeExtractor-->>SemanticSearch: 12
SemanticSearch-->>KeywordExtractor: remaining_text("创建的表格")
KeywordExtractor-->>SemanticSearch: keywords(["创建","表格"])
SemanticSearch-->>User: results(filtered_by_2025_12)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 代码已经非常完善,无需额外修复 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
修复内容
修复文管智能语义搜索在解析"中文数字年份 + 月份 + 文件类型"叠加查询时结果为空的问题。
根因
dfm-search语义搜索时间规则的两处相互依赖缺陷:time_rules.json中三处年份捕获组(?<year>\d{2,4})只匹配阿拉伯数字,不匹配"二五年"/"二零二五年"等中文数字年份。timeextractor.cpp::localeAwareToInt仅处理阿拉伯数字、单个中文数字、含"十"的中文数字,无法解析"二五"(25)、"二零二五"(2025) 等逐位中文数字串。导致"二五年十二月"中年份无法被时间规则消费,"二五年"泄露为搜索关键词,月份被当作当前年(2026)12月,最终查询条件错配 → 结果为空。
触发机理
输入"二五年十二月创建的表格"时:
time_exact_year_month/time_exact_year年份正则\d{2,4}拒绝"二五" → 不命中time_exact_month_current_year(优先级 120),把"十二月"当作当前年 12 月keywords:["二五年"]改动
time_rules.json:time_exact_year/time_exact_year_month/time_exact_full_date年份组扩展为\d{2,4}|[零〇一二三四五六七八九]{2,4},digit_map 补"〇": 0。字符集刻意不含"十"(避免"十二月"被误当年份)、不含"两"。timeextractor.cpp:localeAwareToInt新增逐位中文数字分支(在"十"相关分支之后),将全由 0-9 中文数字组成的串按位拼接。不影响"十一"/"二十"/"十二"等既有解析。tst_chinese_nlp.cpp:新增timeCustom_yearMonth_chineseYear、timeCustom_yearMonth_chineseYear_noResidualKeyword两个回归测试。验证(脚本复现,与开发人员
dfm-searcher -j实测一致)25年十二月创建的表格→ 2025-12 ✅(原已正确)二五年十二月创建的表格→ 2025-12,无残留 keyword ✅(修复后)二五年12月创建的表格→ 2025-12 ✅(修复后)二零二五年十二月创建的表格→ 2025-12 ✅(修复后)二〇二五年十二月创建的表格→ 2025-12 ✅(修复后)十二月的文件→ 仍走 month_current_year,无回归 ✅PMS: https://pms.uniontech.com/bug-view-372165.html
Summary by Sourcery
Support Chinese-numeral years in dfm-search semantic time parsing and ensure they are correctly consumed by year/year-month rules without leaking into keywords.
Bug Fixes:
Enhancements:
Tests: