fix(search): return plain verbose snippets for text search#355
Conversation
Use plain snippets for content and OCR verbose output. 为内容和 OCR 的详细输出使用纯文本片段。 Log: 修复详细搜索结果片段输出 Influence: content/ocr 的 -v 输出改为纯文本,并新增 snippetOffset。
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 |
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 建议将 json_output.cpp 和 text_output.cpp 中重复的代码提取到公共头文件中
// 例如:src/dfm-search/dfm-search-client/output/output_utils.h
#pragma once
#include <dfm-search/searchresult.h>
#include <QRegularExpression>
#include <QString>
namespace dfmsearch {
inline QString plainContentMatch(const SearchResult &result)
{
if (result.hasCustomAttribute("plainContentMatch")) {
return result.customAttribute("plainContentMatch").toString();
}
QString content = result.customAttribute("highlightedContent").toString();
static const QRegularExpression kHtmlTagPattern(QStringLiteral("<[^>]+>"));
return content.remove(kHtmlTagPattern);
}
inline int snippetOffset(const SearchResult &result)
{
return result.hasCustomAttribute("snippetOffset")
? result.customAttribute("snippetOffset").toInt()
: -1;
}
} // namespace dfmsearch
// 然后在 json_output.cpp 和 text_output.cpp 中包含该头文件并移除重复定义 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Use plain snippets for content and OCR verbose output.
为内容和 OCR 的详细输出使用纯文本片段。
Log: 修复详细搜索结果片段输出
Influence: content/ocr 的 -v 输出改为纯文本,并新增 snippetOffset。