叫法消毒做到不再变化、截到第一个分句标点、不许夹带判断词(复核 R12、R18):clean_label 反复去引用标记、数字、符号、空括号直到不变(「销售额[ [v:Q1.r0.gmv] ]」去完数字拼出的「[[v:Q.r.gmv]]」接着去掉),再去掉剩下的方括号、截到第一个分句标点(,。;:!?、,.;:!?)之前、去掉截完没配上对的左括号,整个过程再做到不变,消过的再消一遍不变——复算拿记下的叫法再消,判定语逐字相同。消完的叫法里有说法表的判断词(engine/analysis_claims.scan,在函数里导入)就整个不要,退回下一个来源;目录叫法、当叫法用的列名同一个函数,同样处理

This commit is contained in:
ThearchyHelios
2026-10-21 15:37:48 +08:00
parent cf8ec15831
commit 0acf9fb3a8
3 changed files with 93 additions and 7 deletions
+13
View File
@@ -448,3 +448,16 @@ async def test_dimension_columns_keep_the_type_recorded_at_query_time():
factor_result = await factor([["W41", "1000", 100, "10"], ["W42", "1320", 120, "11"]])
assert factor_result["table"]["column_types"] == {"factor": "text", "base": "number", "target": "number",
"pct": "number", "contrib": "number", "share": "number"}
async def test_a_label_cannot_carry_a_judgment_into_the_phrase():
cut = await additive(label="销售额,主要来自华南")
assert cut["params"]["label"] == "销售额" and cut["phrase"].startswith("销售额下降 194")
assert "华南" not in cut["phrase"]
judged = await additive(label="主要来自华南的销售额")
assert "label" not in judged["params"] # 消成空了,退回目录里的叫法
assert judged["phrase"].startswith("销售额下降 194") and "华南" not in judged["phrase"]
# 消过一遍会变的叫法:复算拿记下的叫法再消,判定语逐字相同(analyze 核对复算逐字段相同)
marked = await additive(label="销售额[ [v:Q1.r0.gmv] ]")
assert marked["params"]["label"] == "销售额" and marked["phrase"].startswith("销售额下降 194")