From 6d8f7b6e2ba79f8947ba4077511b040ae9392d41 Mon Sep 17 00:00:00 2001 From: Jia Sui Date: Sat, 3 Oct 2026 21:06:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor(engine):=20=E7=A7=BB=E9=99=A4=20Autoco?= =?UTF-8?q?rrectCut::has=5Fgenerated=20=E6=AD=BB=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 该字段在 autocorrect_cut_kbest 重建结果时赋值,作为公开结构体字段暴露在头 文件并配了契约注释,但 engine/、server/、windows/ 及全部测试都没有读取点。 静态优先的过滤实际发生在 autocorrect_cut_kbest 内部的 SearchHypothesis 上 (排序比较器 + 末尾按 front().has_generated 决定是否整批 erase),在 cut 重建 之前就完成了。头文件注释把契约归因到这个字段,读者会以为调用方依赖它。 删掉字段与赋值,契约说明改归真正的机制。SearchHypothesis::has_generated 是 活代码,保留。 --- engine/quanpin/quanpin_utils.cpp | 1 - engine/quanpin/quanpin_utils.h | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/engine/quanpin/quanpin_utils.cpp b/engine/quanpin/quanpin_utils.cpp index a80f1e1b..60a74640 100644 --- a/engine/quanpin/quanpin_utils.cpp +++ b/engine/quanpin/quanpin_utils.cpp @@ -980,7 +980,6 @@ std::vector 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) diff --git a/engine/quanpin/quanpin_utils.h b/engine/quanpin/quanpin_utils.h index 49eae31d..89499648 100644 --- a/engine/quanpin/quanpin_utils.h +++ b/engine/quanpin/quanpin_utils.h @@ -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.