From a377a7f66737c32bdf495df010568fb60f62e753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=94=AF?= Date: Tue, 13 Oct 2026 06:00:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(distill):=20t=5F91af03e9=20=E8=A1=A5?= =?UTF-8?q?=E5=81=9C=E7=94=A8=E8=AF=8D=E5=B1=82=E2=80=94=E2=80=94noiseEnti?= =?UTF-8?q?ty=20=E7=B2=BE=E7=A1=AE=E5=8C=B9=E9=85=8D=E6=95=B4=E5=90=8D?= =?UTF-8?q?=E7=9A=84=E7=BB=93=E6=9E=84=E6=80=A7=E6=B3=9B=E8=AF=8D=E8=A1=A8?= =?UTF-8?q?(=E4=BB=BB=E5=8A=A1/=E8=BF=87=E7=A8=8B/=E7=8A=B6=E6=80=81/?= =?UTF-8?q?=E6=B5=81=E7=A8=8B/=E8=AF=8D=E6=B1=87/=E5=B7=A5=E5=85=B7/?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E5=8A=A8=E8=AF=8D/=E5=88=A4=E6=8D=AE/?= =?UTF-8?q?=E7=BB=93=E8=AE=BA/=E7=BB=93=E6=9E=9C/=E6=96=B9=E6=A1=88/?= =?UTF-8?q?=E5=86=85=E5=AE=B9/=E4=BF=A1=E6=81=AF/=E5=8E=9F=E5=9B=A0/?= =?UTF-8?q?=E9=97=AE=E9=A2=98/=E6=AD=A5=E9=AA=A4/=E9=98=B6=E6=AE=B5/?= =?UTF-8?q?=E8=AE=B0=E5=BD=95/=E6=B8=85=E5=8D=95/=E5=A4=87=E6=B3=A8/?= =?UTF-8?q?=E8=AF=B4=E6=98=8E)+=E6=8E=A2=E9=92=88=E6=AE=8B=E7=95=99(?= =?UTF-8?q?=E7=94=B2/=E4=B9=99/=E4=B8=99/=E6=8E=A2=E9=92=88/PROBE=E5=89=8D?= =?UTF-8?q?=E7=BC=80)=EF=BC=9B=E5=85=88=E8=BF=87=E5=81=9C=E7=94=A8?= =?UTF-8?q?=E8=AF=8D=E8=A1=A8=E5=86=8D=E8=B5=B0=E7=8E=B0=E6=9C=89=E6=AD=A3?= =?UTF-8?q?=E5=88=99=EF=BC=9B=E9=95=BF=E5=AE=9E=E4=BD=93=E5=90=8D(?= =?UTF-8?q?=E2=89=A54=E5=AD=97)=E4=B8=8D=E5=9B=A0=E6=9C=AC=E8=A1=A8?= =?UTF-8?q?=E8=A2=AB=E6=8B=A6,=E5=A4=8D=E5=90=88=E5=BD=A2=E6=80=81(?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81/=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=9C=BA)=E7=85=A7=E5=B8=B8=E6=94=BE=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go/internal/governance/graph_auto.go | 25 ++++++++++ go/internal/governance/graph_auto_test.go | 61 ++++++++++++++++++++++- 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/go/internal/governance/graph_auto.go b/go/internal/governance/graph_auto.go index 44e8589..026c557 100644 --- a/go/internal/governance/graph_auto.go +++ b/go/internal/governance/graph_auto.go @@ -294,6 +294,24 @@ var noiseEntityRe = regexp.MustCompile(`(?i)^(ac\d+|ep_|f_|n_|mem_|e_|co_|cw_|df // 绝不承载领域概念,无条件禁进图(与 ep_/f_ 等自ID 前缀同级)。 var kanbanCardIDRe = regexp.MustCompile(`t_[0-9a-f]{6,}`) +// noiseStopwords 停用词表(2026-10-13 t_91af03e9):结构性泛词/探针残留,精确匹配整个实体名。 +// 设计原则——只收「短泛词」,长实体名(≥4 字)天然不会精确命中本表,故领域概念 +// (飞天农业/中维化纤/生物基材料/玉米淀粉深加工/Galway/织忆/鹤壁淇县生物制造产业专班…) +// 一律不因本表被拦。精确匹配(整名相等)而非子串:任务/状态 等单字泛词嵌在「任务状态」「状态机」 +// 「任务已结案」里照常放行(组合形态仍由下方 noiseEntityRe 覆盖)。 +// 唯一例外:工具动词 虽 4 字,但纯结构性工具词、探针丙实测泄漏,显式入表(AC1 硬判据要求拦)。 +var noiseStopwords = map[string]struct{}{ + // 结构性泛词 + "任务": {}, "过程": {}, "状态": {}, "流程": {}, "词汇": {}, "工具": {}, "工具动词": {}, + "判据": {}, "结论": {}, "结果": {}, "方案": {}, "内容": {}, "信息": {}, "原因": {}, + "问题": {}, "步骤": {}, "阶段": {}, "记录": {}, "清单": {}, "备注": {}, "说明": {}, + // 探针/自指残留 + "甲": {}, "乙": {}, "丙": {}, "探针": {}, "probe": {}, +} + +// noiseStopwordPrefixRe 探针前缀形态:^PROBE[-_]?.*(探针丙实测泄漏 PROBE-t62,lower 化后匹配) +var noiseStopwordPrefixRe = regexp.MustCompile(`^probe[-_]?`) + // noiseEntity 实体名命中内容形态噪声 → 跳过写图。 func noiseEntity(name string) bool { n := strings.TrimSpace(name) @@ -308,6 +326,13 @@ func noiseEntity(name string) bool { if kanbanCardIDRe.MatchString(lower) { return true } + // 停用词表:结构性泛词/探针残留,精确匹配整个实体名(先于现有正则) + if _, ok := noiseStopwords[lower]; ok { + return true + } + if noiseStopwordPrefixRe.MatchString(lower) { + return true + } // AC 编号 / 自述模板 / 工具动词 / 看板·任务流程词(组合形态,不单拦泛词) return noiseEntityRe.MatchString(lower) } diff --git a/go/internal/governance/graph_auto_test.go b/go/internal/governance/graph_auto_test.go index 553b25a..ee91372 100644 --- a/go/internal/governance/graph_auto_test.go +++ b/go/internal/governance/graph_auto_test.go @@ -465,7 +465,7 @@ func TestNoiseEntity_KanbanCardIDAndProcessWordDetected(t *testing.T) { } } // 不误杀:领域概念(尤其含 任务/看板/状态 的合法概念)照常放行 - for _, e := range []string{"Docker", "方案B", "织忆", "小怡", "任务", "看板", "系统状态", "状态机", "archive"} { + for _, e := range []string{"Docker", "方案B", "织忆", "小怡", "看板", "系统状态", "状态机", "archive"} { if noiseEntity(e) { t.Errorf("noiseEntity(%q) 应为 false(领域概念误杀)", e) } @@ -525,10 +525,67 @@ func TestNoiseEntity_OldKeywordsSingleMatchRestored(t *testing.T) { // 不误杀:领域概念照常放行(AC3 假阳性护栏) for _, e := range []string{ "鹤壁淇县生物制造产业专班", "飞天农业", "中维化纤", "织忆", "Galway", - "Docker", "方案B", "小怡", "任务", "看板", "系统状态", "状态机", "archive", + "Docker", "方案B", "小怡", "看板", "系统状态", "状态机", "archive", } { if noiseEntity(e) { t.Errorf("noiseEntity(%q) 应为 false(领域概念误杀)", e) } } } + +// ── 补收口三(2026-10-13 t_91af03e9):结构性泛词停用词表(精确匹配整名)── +// 探针丙实测:任务/工具动词/判据/PROBE-t62 等结构性泛词单独成实体时仍漏进图。 +// 旧判据只拦「组合形态」+ 旧关键词,没给「停用词表」——本批补上: +// 结构性泛词/探针残留 精确匹配整个实体名即拦(先于现有正则)。 +// 红线:领域概念(含 4 字以上实体名)不因本表被拦——本表只收短泛词, +// 长实体名天然不会精确命中,且「任务状态/状态机/任务已结案」等复合形态照常放行。 + +// AC1:上列泛词必须全「拦」(逐词打印 拦/放,供终审核对)。 +func TestNoiseEntity_StopwordBlocked(t *testing.T) { + // 上列泛词:结构性泛词 + 探针/自指残留(工具动词 显式入表,AC1 硬判据) + block := []string{ + "任务", "过程", "状态", "流程", "词汇", "工具", "工具动词", + "判据", "结论", "结果", "方案", "内容", "信息", "原因", + "问题", "步骤", "阶段", "记录", "清单", "备注", "说明", + "甲", "乙", "丙", "探针", "PROBE", "PROBE-t62", + } + fail := 0 + for _, e := range block { + got := noiseEntity(e) + mark := "放" + if got { + mark = "拦" + } else { + fail++ + } + t.Logf("%-12s → %s", e, mark) + if !got { + t.Errorf("noiseEntity(%q) 应为 true(停用词表应拦)", e) + } + } + if fail > 0 { + t.Fatalf("停用词表 %d/%d 未拦", fail, len(block)) + } +} + +// AC2:不误杀——7 个红线领域词 + 复合形态照常放行(误杀数必须 = 0)。 +func TestNoiseEntity_StopwordNoFalseKill(t *testing.T) { + keep := []string{ + // 红线 7 个领域词 + "鹤壁淇县生物制造产业专班", "飞天农业", "中维化纤", "玉米淀粉深加工", + "生物基材料", "织忆", "Galway", + // 复合形态(含单字泛词,非精确命中 → 放行;组合形态由 noiseEntityRe 拦) + "信息收集", "状态机", "系统状态", "看板", "Docker", "方案B", "小怡", "archive", + } + kill := 0 + for _, e := range keep { + if noiseEntity(e) { + t.Errorf("noiseEntity(%q) 应为 false(领域概念误杀)", e) + kill++ + } + } + if kill > 0 { + t.Fatalf("误杀 %d 个领域概念", kill) + } + t.Logf("AC2 误杀数 = 0(红线 7 词 + %d 复合形态全放行)", len(keep)-7) +}