Skip to content

feat: enhance semantic search detection logic#334

Merged
Johnson-zs merged 1 commit into
linuxdeepin:semantic-searchfrom
Johnson-zs:semantic-search
Jul 1, 2026
Merged

feat: enhance semantic search detection logic#334
Johnson-zs merged 1 commit into
linuxdeepin:semantic-searchfrom
Johnson-zs:semantic-search

Conversation

@Johnson-zs

Copy link
Copy Markdown
Contributor
  1. Modified document file type detection to include more document
    formats
  2. Completely overhauled semantic query detection logic with new
    requirements
  3. Added new test cases covering various semantic query scenarios
  4. Implemented more granular control over semantic search triggers
  5. Added new utility functions to check semantic intent conditions
  6. Introduced new overload for checking semantic queries from parsed
    intents

The changes improve the accuracy of semantic search detection by:

  1. Requiring explicit content or context for semantic queries
  2. Preventing false positives from single constraints
  3. Better handling of keyword-based semantic searches
  4. More comprehensive document format support
  5. Stricter validation of semantic intent conditions

Log: Improved semantic search accuracy with stricter detection rules

Influence:

  1. Test various document type searches with new supported formats
  2. Verify semantic search triggers only for valid combinations
  3. Check edge cases with partial constraints without targets
  4. Test newly added test cases to ensure proper behavior
  5. Validate keyword-based semantic query detection
  6. Verify performance with new utility functions
  7. Test the new isSemanticQuery overload with pre-parsed intents

feat: 增强语义搜索检测逻辑

  1. 修改文档类型检测以支持更多文档格式
  2. 完全改进了语义查询检测逻辑,加入新要求
  3. 添加了覆盖各种语义查询场景的新测试用例
  4. 实现了更精细的语义搜索触发控制
  5. 添加了检查语义意图条件的新工具函数
  6. 新增了用于检查已解析意图语义查询的重载函数

这些改进通过以下方式提高了语义搜索检测的准确性:

  1. 要求明确的内容或上下文才能触发语义查询
  2. 防止来自单一条件的误报
  3. 更好地处理基于关键字的语义搜索
  4. 更全面的文档格式支持
  5. 更严格的语义意图条件验证

Log: 通过更严格的检测规则提高语义搜索准确性

Influence:

  1. 测试使用新支持格式的各种文档类型搜索
  2. 验证语义搜索仅在有效组合时触发
  3. 检查带有目标的部分约束边缘情况
  4. 测试新添加的测试用例以确保正确行为
  5. 验证基于关键字的语义查询检测
  6. 使用新工具函数测试性能
  7. 测试新的isSemanticQuery重载功能与预解析意图

@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.

Sorry @Johnson-zs, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@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

1. Modified document file type detection to include more document
formats
2. Completely overhauled semantic query detection logic with new
requirements
3. Added new test cases covering various semantic query scenarios
4. Implemented more granular control over semantic search triggers
5. Added new utility functions to check semantic intent conditions
6. Introduced new overload for checking semantic queries from parsed
intents

The changes improve the accuracy of semantic search detection by:
1. Requiring explicit content or context for semantic queries
2. Preventing false positives from single constraints
3. Better handling of keyword-based semantic searches
4. More comprehensive document format support
5. Stricter validation of semantic intent conditions

Log: Improved semantic search accuracy with stricter detection rules

Influence:
1. Test various document type searches with new supported formats
2. Verify semantic search triggers only for valid combinations
3. Check edge cases with partial constraints without targets
4. Test newly added test cases to ensure proper behavior
5. Validate keyword-based semantic query detection
6. Verify performance with new utility functions
7. Test the new isSemanticQuery overload with pre-parsed intents

feat: 增强语义搜索检测逻辑

1. 修改文档类型检测以支持更多文档格式
2. 完全改进了语义查询检测逻辑,加入新要求
3. 添加了覆盖各种语义查询场景的新测试用例
4. 实现了更精细的语义搜索触发控制
5. 添加了检查语义意图条件的新工具函数
6. 新增了用于检查已解析意图语义查询的重载函数

这些改进通过以下方式提高了语义搜索检测的准确性:
1. 要求明确的内容或上下文才能触发语义查询
2. 防止来自单一条件的误报
3. 更好地处理基于关键字的语义搜索
4. 更全面的文档格式支持
5. 更严格的语义意图条件验证

Log: 通过更严格的检测规则提高语义搜索准确性

Influence:
1. 测试使用新支持格式的各种文档类型搜索
2. 验证语义搜索仅在有效组合时触发
3. 检查带有目标的部分约束边缘情况
4. 测试新添加的测试用例以确保正确行为
5. 验证基于关键字的语义查询检测
6. 使用新工具函数测试性能
7. 测试新的isSemanticQuery重载功能与预解析意图
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码成功重构了语义搜索判断逻辑,引入TargetExtractor并优化了意图识别规则
逻辑清晰且无安全漏洞,因测试代码存在逻辑重复扣5分

■ 【详细分析】

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

代码实现了TargetExtractor的完整生命周期管理和规则加载,isSemanticIntent通过多个辅助函数清晰表达了组合判断逻辑,测试用例准确覆盖了新增的target规则及重构后的边界条件
建议:保持当前良好的函数拆分习惯

  • 2.代码质量(良好)✓

主业务代码通过提取hasKeywordRuleSpan等辅助函数大幅提升了可读性,但tst_semantic_search.cpp中的checkIsSemanticQuery函数完全复制了semanticsearcher.cpp中isSemanticIntent的判断逻辑,导致双重维护成本
潜在问题:测试辅助函数与生产代码逻辑高度耦合,未来修改判断规则时极易遗漏同步更新测试代码
建议:将测试中的checkIsSemanticQuery改为直接调用公开的SemanticSearcher::isSemanticQuery接口,以真实行为作为测试基准

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

新增的hasKeywordRuleSpan和hasTargetRuleSpan等函数虽然对consumedSpans进行了多次线性遍历,但在NLP解析场景下该集合元素数量极少,不会产生可感知的性能损耗
建议:无需优化

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码仅涉及内存中的字符串正则匹配和逻辑判断,target_rules.json中的正则表达式均为简单的字面量或基本交替匹配,无回溯风险,不涉及任何外部命令执行、文件系统越权或敏感数据泄露
建议:继续保持对用户输入使用成熟的QRegularExpression进行安全匹配

■ 【改进建议代码示例】

// autotests/dfm-search-tests/tst_semantic_search.cpp
// 建议在 tst_IsSemanticQuery 测试类中增加成员变量并在初始化时赋值
// SemanticSearcher *m_searcher = nullptr;

// void tst_IsSemanticQuery::initTestCase() {
//     m_searcher = new SemanticSearcher(this);
//     // ... 原有初始化逻辑 ...
// }

// 移除重复的判断逻辑,直接使用被测接口实现测试辅助函数
bool checkIsSemanticQuery(SemanticRuleEngine *engine, IntentParser *parser,
                          const QString &input, SemanticSearcher *searcher)
{
    Q_UNUSED(engine)
    ParsedIntent intent;
    parser->parse(input, intent);
    
    // 直接复用生产环境的重载方法,避免测试与实现逻辑脱节
    return searcher->isSemanticQuery(intent);
}

@Johnson-zs Johnson-zs merged commit 34c1a9b into linuxdeepin:semantic-search Jul 1, 2026
20 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