docs(engine): 补上下文重排切分与用例打分的前提说明

R2 的分层判据是 canonical_pinyin == winner_key。原注释只说明了「整句与词格行
同键」,没解释为什么整键档**必然**是 winner_key。而 query_single_cut_keyed 在精确
键查空时会退到前缀区间扫描,那类行的 canonical 是别的读音(gun'qi 捞出 gun'qiu),
放宽判据就会静默把同档整词沉到末尾——正是本任务在修的那类回归。补上这条不变量:
decode_pool 由 query_exact_segmentations_keyed_flat 只收精确键构造,词库里没有整词的
切分进不了池,这条路在胜出切分上不可达。

测试侧补上「fixture 无 sc.lm ⇒ 启发式打分 ⇒ 用例确定」这个前提(同组 ranking fixture
已有,新用例依赖同一前提却没写)。
This commit is contained in:
Jia Sui committed 2026-10-04 03:45:53 +08:00
1 parent e1331ff1dc
commit bbebd34d22
2 files changed
+8

No files matched your search

+2
View File
@@ -416,6 +416,8 @@ void run_autocorrect_context_ranking_tests(const std::filesystem::path &data_dir
// 办证/辩证/整句还带着首音节的单字;这些单字排在 rest(班长、搬账)之前,把同键位的
// 其他整词整组挤出首页。原 fixture 没有 tbl_1_b,前缀这条路根本没被走到。
// 这里补单字表,并直接断言「整键在前、前缀在后」这条分层不变量。
// 同上一组 fixture:词库目录里没有 sc.lm,词格退回启发式打分,权重完全决定路径分,
// 因此 zheng 侧稳定胜出、重排稳定接管,用例不依赖任何模型文件。
void run_autocorrect_context_layering_tests(const std::filesystem::path &data_directory)
{
const std::filesystem::path directory = data_directory / "autocorrect-context-layering";