refactor(engine): 移除 AutocorrectCut::has_generated 死字段

该字段在 autocorrect_cut_kbest 重建结果时赋值,作为公开结构体字段暴露在头
文件并配了契约注释,但 engine/、server/、windows/ 及全部测试都没有读取点。

静态优先的过滤实际发生在 autocorrect_cut_kbest 内部的 SearchHypothesis 上
(排序比较器 + 末尾按 front().has_generated 决定是否整批 erase),在 cut 重建
之前就完成了。头文件注释把契约归因到这个字段,读者会以为调用方依赖它。

删掉字段与赋值,契约说明改归真正的机制。SearchHypothesis::has_generated 是
活代码,保留。
This commit is contained in:
Jia Sui committed 2026-10-04 03:45:53 +08:00
1 parent 7a8b441509
commit 6d8f7b6e2b
2 files changed
+1 -8

No files matched your search

-1
View File
@@ -980,7 +980,6 @@ std::vector<AutocorrectCut> autocorrect_cut_kbest(const std::string &pinyin, con
AutocorrectCut cut;
cut.edge_count = hypothesis.edge_count;
cut.weight = hypothesis.weight;
cut.has_generated = hypothesis.has_generated;
size_t position = length;
const SearchHypothesis *current = &hypothesis;
while (current->prev_index != kNoPredecessor)
+1 -7
View File
@@ -112,11 +112,6 @@ struct AutocorrectCut
// (neighbor gau -> gai, weight 13) regardless of dictionary frequency.
size_t edge_count = 0;
int weight = 0;
// True when any edge of this cut is an out-of-table generated pair. The
// search itself drops generated-containing cuts whenever a pure-static cut
// tops the ranking, so in-table inputs consume exactly the baseline cut
// set.
bool has_generated = false;
bool empty() const
{
@@ -152,8 +147,7 @@ Segments autocorrect_cut(const std::string &pinyin, unsigned autocorrect_types);
// when the top cut is pure static all generated cuts are dropped before
// returning -- in-table inputs get exactly the pre-generated-space cut set,
// and out-of-table shapes surface only when no static cut explains the input.
// Every
// returned cut contains at least one corrected edge, so a fully legal input
// Every returned cut contains at least one corrected edge, so a fully legal input
// with no correction reading yields an empty vector (the caller owns the plain
// segmentation). This is the query-time disambiguation surface of CN 101133411
// B: ambiguity survives the cut layer and is settled by dictionary frequency.