fix(chat): drop hedges, vote/closure wording and 激活 from 判断依据 (BUG-2137)
Staging round 27: chat answers' 判断依据 still showed 「只作参考」-type hedges, 「不另计一票」/「未闭环」/「两套体系确认」 and 「共同激活」. New chat-basis-clean module cleans them clause by clause (numbers never dropped) in the display, the final scrub and the reword round; the chat word table no longer writes 「只作参考」 back. The 「落陷阱」 typo was model-written; display separates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
This commit is contained in:
@@ -28902,3 +28902,20 @@
|
||||
- 验证与防复发:`frontend/tests/login-heading-clip-20261121.test.ts`(密码登录没有说明段时页签跟在标题后、基础规则不得是负上边距、返回登录间距);本地生产构建 7 种宽度 × 浅深色 × 四种登录状态的改前改后截图对比。教训:不要用负边距去抵消一个有时不渲染的元素的边距。
|
||||
- 关联记录:BUG-1662、BUG-1663、BUG-1664、BUG-1670。
|
||||
- 修复版本:`claude/birth-coordinates-2125`。
|
||||
|
||||
## BUG-2137 | 问答「判断依据」里仍有「只作参考」类保留话、计票/闭环口吻和「共同激活」
|
||||
|
||||
- 状态:fixed-pending-verify
|
||||
- 现象:staging 复测第二十七轮,三个问答回答的「判断依据」里有「该年盘标只作参考」「标为参考」「年盘取数本身只作参考」「仅作参考」「不另计一票」「Narayana 的当前分支因双体系比较未闭环,保留为条件性窗口」「仍不写成两套体系确认」「木星与土星共同激活第 10 宫」,以及错字「宫内木星落陷阱有取消」。回答正文没有问题。
|
||||
- 触发条件:模型把证据卡里的保留话和分层规则原句抄进判断依据;问答用词检查只认字段名、英文、证据编号和出处(BUG-2133),不认这三类;问答用词表自己还会写回「只作参考」(「为参数敏感」「参数敏感」「按来源只为参考」三行)。
|
||||
- 根因:报告侧的保留话(BUG-2097、BUG-2101)、后台口吻(占星师 11-19 分层规则)和「激活」(BUG-2126)已经处理,问答判断依据没有跟上;用词表的替换值本身就是保留话。错字不是我们的表造成的:`frontend/src`、`scripts`、`references` 里没有任何表会写出「阱」,已存的 staging 回答里「落陷阱」只出现 2 次,是模型写的。
|
||||
- 修复:
|
||||
- 新模块 `frontend/src/lib/chat-basis-clean.ts`:`withoutBasisNoise` 按半句清理——只有保留话或规则口吻的半句整个去掉,带日期、数字或盘面内容的只去掉那几个字;带数字的半句不会整个删;「共同激活」→「同时关联到」、「激活/引动」→「关联到」;「落陷阱有」→「落陷,有」;条目标题去掉「只作结构参考」「不额外计票」,技法名保留(负责人决定前不删技法名)。保留话的写法与报告的 `readingHedge` 同一形状,另加「标为参考」。
|
||||
- 显示:`parseJudgmentBasisItems`(条目标题和事实句)和 `chat-message-content.tsx` 的 markdown 兜底都先过 `withoutBasisNoise`,已存的回答也生效。
|
||||
- 检查:`consultation-internal-words.ts` 把这三类算作判断依据行里的内部说法,进入现有的一次改写;改写说明加一行「「只作参考」一类的保留话、计票和闭环这类规则口吻都去掉;「激活」写成「有关联」」,每个词有自己的说明。`scrubInternalWords` 在表替换前后各清理一次。
|
||||
- 用词表:「为参数敏感」「参数敏感」改为「(的)结果会随算法设置变化」(报告 BUG-2130 的说法),「按来源只为参考」改为去掉。
|
||||
- 验证:新增 `frontend/tests/chat-basis-2137.test.ts`(第二十七轮原句、标题、改写轮、用词表);`consult-internal-words-1948` 四处预期按新口径更新并注明原值/新值/原因。已存回答统计(显示层,`/workspace/eval-read-1116` 下 573 个带判断依据的回答):带这三类词的判断依据行 481 → 0(激活 348、后台口吻 81、保留话 169 处),没有丢失任何数字或日期;第二十六轮 5 → 0,第二十七轮 11 → 0。tsc 通过,eslint 0 错误,前端全量 4651 项里 28 项失败,都是本机缺数据库/Python 引擎环境的既有失败。
|
||||
- 防复发:判断依据的显示、检查和改写说明共用 `chat-basis-clean.ts`;用词表不再产出保留话(有测试)。
|
||||
- 未覆盖:回答正文不清理(正文本轮没有问题);「双体系确认」「只作条件性窗口」等仍由原有表行处理,没有扩大。
|
||||
- 关联记录:BUG-2133、BUG-2101、BUG-2097、BUG-2126、BUG-2030、BUG-2011。
|
||||
- 修复版本:`claude/chat-basis-2137`。
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ConsultJudgmentBasis } from "@/components/consult-judgment-basis";
|
||||
import type { ConsultChartData } from "@/lib/consult-chart-data";
|
||||
import { splitJudgmentBasis } from "@/lib/consult-judgment-basis";
|
||||
import { withoutChatCitations } from "@/lib/report-citations";
|
||||
import { withoutBasisNoise } from "@/lib/chat-basis-clean";
|
||||
import {
|
||||
answerUsedBookLibrary,
|
||||
consultScopeLine,
|
||||
@@ -184,7 +185,7 @@ export function ChatMessageContent({
|
||||
{report ? <div className="answer-report-body">{reportBody}</div> : foldedAudit}
|
||||
{judgment.basis ? (
|
||||
<ConsultJudgmentBasis basis={judgment.basis}>
|
||||
<StreamingMarkdown text={withoutChatCitations(judgment.basis)} renderMarkdown={renderMarkdown} streaming={streaming} />
|
||||
<StreamingMarkdown text={withoutBasisNoise(withoutChatCitations(judgment.basis))} renderMarkdown={renderMarkdown} streaming={streaming} />
|
||||
</ConsultJudgmentBasis>
|
||||
) : null}
|
||||
{!streaming && chartData ? <ConsultChartDataFold data={chartData} /> : null}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* BUG-2137 (staging 复测第二十七轮): what a chat answer's 「判断依据」 still showed after BUG-2133 — 「只作参考」-type
|
||||
* hedges (「该年盘标只作参考」「标为参考」「年盘取数本身只作参考」「仅作参考」), backstage rule wording (「不另计一票」
|
||||
* 「因双体系比较未闭环,保留为条件性窗口」「仍不写成两套体系确认」) and 「共同激活」. Reports dropped all three
|
||||
* already (BUG-2097 / 2101 hedges, 占星师 11-19 分层规则, BUG-2126 激活); the same rule now holds for the basis
|
||||
* shown under an answer, stored answers included.
|
||||
*
|
||||
* A clause that is only such a note goes; a hedge attached to content leaves the content. A clause is never
|
||||
* dropped when it carries a number, so no date, degree or score is lost. Technique names stay (owner decision
|
||||
* pending), and the classical gist (「传统说法:」) is untouched.
|
||||
*/
|
||||
|
||||
/** 「只作参考」「仅作参考」「仅供参考」「只能作为参考」「标为参考」「标成参考」. Same shape as the report check (readingHedge). */
|
||||
const HEDGE = /(?:(?:只|仅)(?:能)?(?:作|供|当|用作|作为)[^。,;,;::!?!?\s]{0,4}?参考|标(?:为|成|作)参考)/u;
|
||||
/** Rule, vote and closure wording the astrologer keeps backstage (11-19 分层规则). */
|
||||
// Narrow on purpose: 「只作条件性窗口」 is a title word and 「双体系确认」 has its own row in the chat table
|
||||
// (→「两种方法一致」); only the clauses round twenty-seven showed are dropped here.
|
||||
const BACKSTAGE = /不另计一票|另计一票|不额外计票|不计票|计票|投票|未闭环|没有闭环|双体系比较|两套体系确认|保留为条件性窗口|各步虽已定/u;
|
||||
/** 激活-type wording (BUG-2126): the matter connects to the period's planet, nothing is 「activated」. */
|
||||
const ACTIVATION: ReadonlyArray<readonly [RegExp, string]> = [
|
||||
[/(?:共同|双重|同时)激活/gu, "同时关联到"],
|
||||
[/被激活|被点亮|被触发|被引动/gu, "有关联"],
|
||||
[/激活|引动/gu, "关联到"],
|
||||
];
|
||||
/** What is left of a hedge clause that names nothing: 「该年盘标」「年盘取数本身」「两项」. */
|
||||
const LEFTOVER_TAIL = /(?:本身|本身也|也|都|均|则|标|已)+$/u;
|
||||
const LEAD_CONNECTOR = /^(?:且|但|而|并且|并)\s*/u;
|
||||
const CONNECTOR_ONLY = /^(?:且|但|而|并且|并)$/u;
|
||||
/** 「各步已定,但」: a connector the chat table left at the end of a line (its clause had nothing to keep). */
|
||||
const TRAILING_CONNECTOR = /[,,;;]\s*(?:且|但|而|并且)\s*(?=[。!?]?\s*$)/u;
|
||||
const HAS_NUMBER = /\d/u;
|
||||
|
||||
/** Clauses at the top level of a line: 「,;,;」 outside parentheses split them; the separator stays with the clause before it. */
|
||||
function clauses(line: string): Array<{ text: string; sep: string }> {
|
||||
const out: Array<{ text: string; sep: string }> = [];
|
||||
let depth = 0;
|
||||
let current = "";
|
||||
for (const char of line) {
|
||||
if (char === "(" || char === "(") depth += 1;
|
||||
if ((char === ")" || char === ")") && depth > 0) depth -= 1;
|
||||
if (depth === 0 && /[,;,;]/u.test(char)) {
|
||||
out.push({ text: current, sep: char });
|
||||
current = "";
|
||||
continue;
|
||||
}
|
||||
current += char;
|
||||
}
|
||||
out.push({ text: current, sep: "" });
|
||||
return out;
|
||||
}
|
||||
|
||||
function cleanClause(text: string): string | null {
|
||||
const trimmed = text.trim();
|
||||
if (!trimmed) return null;
|
||||
if (BACKSTAGE.test(trimmed)) {
|
||||
// A clause that is only rule wording goes; one that also carries a number keeps everything but the phrase.
|
||||
if (!HAS_NUMBER.test(trimmed)) return null;
|
||||
return trimmed.replace(new RegExp(BACKSTAGE.source, "gu"), "").trim() || null;
|
||||
}
|
||||
if (!HEDGE.test(trimmed)) return trimmed;
|
||||
const residue = trimmed.replace(new RegExp(HEDGE.source, "gu"), "").replace(LEFTOVER_TAIL, "").trim();
|
||||
if (!residue) return null;
|
||||
// 「该年盘」「年盘取数」: a bare subject of the dropped hedge says nothing on its own.
|
||||
if (!HAS_NUMBER.test(residue) && [...residue].length <= 6) return null;
|
||||
return residue;
|
||||
}
|
||||
|
||||
/**
|
||||
* An item title without the hedge or vote wording: 「年运只作结构参考」 → 「年运」, 「KP 与整宫并列、不额外计票」 →
|
||||
* 「KP 与整宫并列」, 「KP 一面(只作参考,有条件参考)」 → 「KP 一面(有条件参考)」. A title that would be empty stays.
|
||||
*/
|
||||
export function basisTitleWithoutNoise(title: string): string {
|
||||
const cleaned = title
|
||||
.replace(new RegExp(`[、,,]?\\s*(?:${HEDGE.source})`, "gu"), "")
|
||||
.replace(/[、,,]?\s*(?:不额外|不另|另)?(?:计票|计一票)/gu, "")
|
||||
.replace(/[((]\s*[,,、]\s*/gu, (match) => match.charAt(0))
|
||||
.replace(/[((]\s*[))]/gu, "")
|
||||
.trim();
|
||||
return cleaned || title;
|
||||
}
|
||||
|
||||
function cleanLine(line: string): string {
|
||||
const head = /^(\s*(?:[-*]\s+|\d+[.、]\s*)?\*\*)([^*]+)(\*\*)/u.exec(line);
|
||||
if (head && (HEDGE.test(head[2]!) || BACKSTAGE.test(head[2]!) || /计票/u.test(head[2]!))) {
|
||||
line = `${head[1]}${basisTitleWithoutNoise(head[2]!)}${head[3]}${line.slice(head[0].length)}`;
|
||||
}
|
||||
if (!HEDGE.test(line) && !BACKSTAGE.test(line)) return line;
|
||||
const lead = /^(\s*(?:[-*]\s+|\d+[.、]\s*)?(?:\*\*[^*]+\*\*[::]?\s*)?)/u.exec(line)?.[1] ?? "";
|
||||
const end = /[。!?]\s*$/u.exec(line)?.[0] ?? "";
|
||||
const body = line.slice(lead.length, line.length - end.length);
|
||||
const kept: Array<{ text: string; sep: string }> = [];
|
||||
let dropped = false;
|
||||
for (const part of clauses(body)) {
|
||||
const text = cleanClause(part.text);
|
||||
if (text === null || CONNECTOR_ONLY.test(text)) {
|
||||
// The separator of a dropped clause moves back onto the clause before it (「…,不另计一票。」 → 「…。」).
|
||||
dropped = true;
|
||||
continue;
|
||||
}
|
||||
// 「该年盘标只作参考,且本轮只解释事业」: the 「且」 joined the dropped clause, not the one before it.
|
||||
kept.push({ text: !kept.length || dropped ? text.replace(LEAD_CONNECTOR, "") : text, sep: part.sep });
|
||||
dropped = false;
|
||||
}
|
||||
if (!kept.length) return "";
|
||||
const joined = kept.map((part, index) => (index < kept.length - 1 ? `${part.text}${part.sep || ","}` : part.text)).join("");
|
||||
return `${lead}${joined}${end}`;
|
||||
}
|
||||
|
||||
/** One 「判断依据」 text (a line, an item or the whole section) as the reader sees it. */
|
||||
export function withoutBasisNoise(text: string): string {
|
||||
if (!text) return text;
|
||||
let out = text;
|
||||
// The model wrote 「宫内木星落陷阱有取消」 (round twenty-seven): 「落陷」 and 「有取消」 run together.
|
||||
out = out.replace(/落陷阱(?=有|但|且|,|、)/gu, "落陷,").replace(/,,/gu, ",");
|
||||
for (const [pattern, word] of ACTIVATION) out = out.replace(pattern, word);
|
||||
const lines = out.split("\n");
|
||||
const cleaned = lines.map((line) => cleanLine(line).replace(TRAILING_CONNECTOR, ""));
|
||||
// A list line that lost everything goes with its line break; other lines keep their place.
|
||||
return cleaned.filter((line, index) => line !== "" || lines[index] === "").join("\n");
|
||||
}
|
||||
|
||||
|
||||
export type BasisNoiseKind = "hedge" | "backstage" | "activation";
|
||||
|
||||
/** Spans of hedge, rule wording and 激活 in one basis line (for the check and the rewrite round). */
|
||||
export function basisNoiseSpans(text: string): Array<{ start: number; end: number; token: string; noise: BasisNoiseKind }> {
|
||||
const spans: Array<{ start: number; end: number; token: string; noise: BasisNoiseKind }> = [];
|
||||
const rows: ReadonlyArray<readonly [RegExp, BasisNoiseKind]> = [
|
||||
[new RegExp(HEDGE.source, "gu"), "hedge"],
|
||||
[new RegExp(BACKSTAGE.source, "gu"), "backstage"],
|
||||
[/(?:共同|双重|同时)?激活|被点亮|被触发|引动/gu, "activation"],
|
||||
];
|
||||
for (const [pattern, noise] of rows) {
|
||||
for (const match of text.matchAll(pattern)) {
|
||||
const start = match.index;
|
||||
const end = start + match[0].length;
|
||||
if (spans.some((span) => start < span.end && end > span.start)) continue;
|
||||
spans.push({ start, end, token: match[0], noise });
|
||||
}
|
||||
}
|
||||
return spans.sort((a, b) => a.start - b.start);
|
||||
}
|
||||
|
||||
/** What the rewrite round is told about one flagged token, or null when it is not basis noise. */
|
||||
export function basisNoiseMeaning(token: string): string | null {
|
||||
if (HEDGE.test(token)) return `${token}:「只作参考」一类的保留话,读者不需要;只说这几个字的半句整个去掉,半句里有日期、数字或盘面内容时只去掉这几个字`;
|
||||
if (BACKSTAGE.test(token)) return `${token}:后台的规则口吻(计票、闭环、体系确认),读者不需要;连同它所在的半句一起去掉,日期和数字留下`;
|
||||
if (/激活|被点亮|被触发|引动/u.test(token)) return `${token}:不写「激活」一类的说法,写成「和……有关联」或「关联到」`;
|
||||
return null;
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
* folds this section.
|
||||
*/
|
||||
import { CLASSICAL_GIST_LEAD, withoutChatCitations } from "./report-citations.ts";
|
||||
import { basisTitleWithoutNoise, withoutBasisNoise } from "./chat-basis-clean.ts";
|
||||
|
||||
export const CONSULT_JUDGMENT_BASIS_TITLE = "判断依据";
|
||||
|
||||
@@ -150,11 +151,12 @@ export function parseJudgmentBasisItems(basis: string): JudgmentBasisItem[] | nu
|
||||
}
|
||||
// BUG-2133: shown without book titles, authors, tables, chapters and pages (stored answers too); a classical
|
||||
// passage keeps its gist after 「传统说法:」 and is still marked as the book line.
|
||||
const facts = basisSentences(withoutChatCitations(rest.replace(/\*\*|`/g, ""))).map((text) => ({
|
||||
// BUG-2137: and without 「只作参考」-type hedges, rule wording (计票、闭环) or 激活.
|
||||
const facts = basisSentences(withoutBasisNoise(withoutChatCitations(rest.replace(/\*\*|`/g, "")))).filter((text) => text.trim()).map((text) => ({
|
||||
text,
|
||||
book: text.includes("《") || text.startsWith(CLASSICAL_GIST_LEAD),
|
||||
}));
|
||||
items.push({ title: lead[1].replace(/[::]\s*$/, "").trim(), facts, grade, note });
|
||||
items.push({ title: basisTitleWithoutNoise(lead[1].replace(/[::]\s*$/, "").trim()), facts, grade, note });
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CLASSICAL_GIST_LEAD, citationHits, citationSpans, withoutChatCitations } from "./report-citations.ts";
|
||||
import { basisNoiseMeaning, basisNoiseSpans, withoutBasisNoise } from "./chat-basis-clean.ts";
|
||||
import { EVIDENCE_ID_PATTERN, EVIDENCE_ID_PREFIX, LOGICAL_KEY_PREFIX } from "./evidence-ids.ts";
|
||||
import { splitJudgmentBasis } from "./consult-judgment-basis.ts";
|
||||
import { FACT_STATUS_LABELS } from "./report-fact-table-display.ts";
|
||||
@@ -26,7 +27,8 @@ import { YOGA_STATUS_MAPPING } from "./yoga-status-words.ts";
|
||||
*/
|
||||
|
||||
// BUG-2011 原值「换一种算法设置结果会变」/ 新值「只作参考」/ 原因:复测时表替换成「年盘为换一种算法设置结果会变层」,长句塞进别的句子读不通
|
||||
const INTERNAL_CHINESE_PHRASES_PARAMETER = "只作参考";
|
||||
// BUG-2137 原值「只作参考」/ 新值「结果会随算法设置变化」/ 原因:表自己往「判断依据」里写回保留话(复测第二十七轮);用报告 BUG-2130 的说法
|
||||
const INTERNAL_CHINESE_PHRASES_PARAMETER = "结果会随算法设置变化";
|
||||
const YOGA_UNDECIDED_PLAIN = "这一点目前还不能明确判断";
|
||||
|
||||
/** Existing wording only. Source of each row is in references/product_runtime_contract.md §V. */
|
||||
@@ -161,7 +163,8 @@ export type InternalWordHit = { start: number; end: number; token: string; kind?
|
||||
export const INTERNAL_CHINESE_PHRASES: Readonly<Record<string, string>> = {
|
||||
// BUG-2041: before 「参数敏感」, so 「KP 为参数敏感」 does not become 「KP 为只作参考」.
|
||||
"为参数敏感层": "为参考层",
|
||||
"为参数敏感": "只作参考",
|
||||
// BUG-2137 原值「只作参考」/ 新值「的结果会随算法设置变化」/ 原因:同上
|
||||
"为参数敏感": "的结果会随算法设置变化",
|
||||
"按卡上的状态": "",
|
||||
"按卡上状态": "",
|
||||
"按卡上": "",
|
||||
@@ -197,7 +200,8 @@ export const BASIS_ONLY_WORDS: Readonly<Record<string, string>> = {
|
||||
"落陷已取消": "落陷的不利影响有缓解因素",
|
||||
"落陷取消": "不利影响有缓解因素",
|
||||
"分界敏感": "出生时间前后几分钟会影响这一条",
|
||||
"按来源只为参考": "只作参考",
|
||||
// BUG-2137 原值「只作参考」/ 新值「」(去掉)/ 原因:同上
|
||||
"按来源只为参考": "",
|
||||
// BUG-2041 (复测第十轮):格局状态表的文字、其余后台口吻和替换后的病句。
|
||||
// The status table's own texts (yoga-status-words.ts, the one table) and the spellings answers made of them.
|
||||
[`被${YOGA_STATUS_MAPPING.computed.text}`]: YOGA_UNDECIDED_PLAIN,
|
||||
@@ -420,6 +424,11 @@ export function findInternalWords(text: string, options: { english?: boolean; en
|
||||
if (hits.some((other) => hit.start < other.end && hit.end > other.start)) continue;
|
||||
hits.push(hit);
|
||||
}
|
||||
// BUG-2137: hedges, rule wording and 激活 in a 「判断依据」 line go to the rewrite round too.
|
||||
for (const span of basisNoiseSpans(text)) {
|
||||
if (hits.some((other) => span.start < other.end && span.end > other.start)) continue;
|
||||
hits.push({ start: span.start, end: span.end, token: span.token, kind: "phrase" });
|
||||
}
|
||||
}
|
||||
// BUG-2133 (产品负责人 2026-11-21): book titles, authors, tables, chapters and pages are not shown with an
|
||||
// answer either. A citation replaces any other hit inside it (「Raman」 is not also an English word).
|
||||
@@ -477,6 +486,11 @@ function wordMeanings(units: readonly InternalWordUnit[]): string[] {
|
||||
for (const token of units.flatMap((unit) => unit.tokens)) {
|
||||
if (seen.has(token)) continue;
|
||||
seen.add(token);
|
||||
const noise = basisNoiseMeaning(token);
|
||||
if (noise) {
|
||||
lines.push(noise);
|
||||
continue;
|
||||
}
|
||||
if (citationHits(token).length) {
|
||||
lines.push(`${token}:书名、作者、表号、章节或页码,去掉;这条传统说法只留它的大意,写成「${CLASSICAL_GIST_LEAD}……」`);
|
||||
continue;
|
||||
@@ -536,6 +550,7 @@ export function internalWordRepairPrompt(units: readonly InternalWordUnit[]): st
|
||||
"- 只把列出的那几个词换成给出的中文说法;标着没有实际意思的,连同它所在的空括号或半句一起去掉。",
|
||||
"- 其余内容一个字不改:星、星座、宫、度数、日期、分盘和技法的名称、行尾的等级标注都照原样保留。",
|
||||
`- 书名、作者、表号、章节和页码一律去掉(BUG-2133);古书的说法只留大意,前面写「${CLASSICAL_GIST_LEAD}」。`,
|
||||
"- 「只作参考」一类的保留话、计票和闭环这类规则口吻都去掉;「激活」写成「有关联」(BUG-2137)。",
|
||||
"- 每行仍是一行,行首的「- **……**」照原样保留;不新增判断,不新增依据。",
|
||||
"- 只输出 JSON 数组:[{\"id\": 1, \"text\": \"改写后的整行\"}],不要别的文字。",
|
||||
"",
|
||||
@@ -592,7 +607,8 @@ export function scrubInternalWords(line: string): string {
|
||||
};
|
||||
// BUG-1976: evidence ids go first, with the separators around them. BUG-2041: then copied writing instructions.
|
||||
// BUG-2133: book leads become 「传统说法:」 and report-style citations go before the word table runs.
|
||||
let text = withoutChatCitations(dropMetaClauses(dropEvidenceIds(line)));
|
||||
// BUG-2137: hedges, rule wording and 激活 leave the line by clause before the word table runs.
|
||||
let text = withoutBasisNoise(withoutChatCitations(dropMetaClauses(dropEvidenceIds(line))));
|
||||
for (const hit of findInternalWords(text).filter((item) => item.token.includes(": ")).reverse()) {
|
||||
// A one-word key set to true names a chart term (「vargottama: true」 keeps 「vargottama」); any other
|
||||
// fragment without a table row carries nothing for the reader.
|
||||
@@ -650,6 +666,8 @@ export function scrubInternalWords(line: string): string {
|
||||
const headPart = word.split(/[,,]/)[0]!;
|
||||
if (headPart !== word) text = text.replace(new RegExp(`${esc(headPart)}([((])${esc(word)}[,,、]?`, "gu"), `${word}$1`);
|
||||
}
|
||||
// BUG-2137: the table can write a hedge back (「只作为单体系候选」→「只作为参考」), so the clean-up runs once more.
|
||||
text = withoutBasisNoise(text);
|
||||
return text
|
||||
.replace(/[【\[][\s,,、;;::]*[】\]]/gu, "")
|
||||
.replace(/[((][\s,,、;;::]*[))]/gu, "")
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { basisNoiseSpans, basisTitleWithoutNoise, withoutBasisNoise } from "../src/lib/chat-basis-clean.ts";
|
||||
import { parseJudgmentBasisItems } from "../src/lib/consult-judgment-basis.ts";
|
||||
import { internalWordRepairPrompt, scanInternalWords, scrubInternalWords } from "../src/lib/consultation-internal-words.ts";
|
||||
|
||||
// BUG-2137: lines from staging 复测第二十七轮 (chart details trimmed).
|
||||
const ROUND27 = [
|
||||
"- **年盘**:2026-08-08 至 2027-08-08 年盘,年主木星,Mudda 土星 2026-11-10 至 2027-01-07;该年盘标只作参考,且本轮只解释事业。",
|
||||
"- **N**:Narayana 主运天秤(第 4 宫,2018-08-08 至 2028-08-07),与 Vimshottari 的小运主星是同一个盘面事实,不另计一票",
|
||||
"- **N2**:子运金牛(第 11 宫,2026-02-06 至 2026-12-08);标为参考,各步虽已定,仍不写成两套体系确认",
|
||||
"- **T**:木星与土星共同激活第 10 宫的区段为 2027-02-05 至 2027-05-20(D1 层)",
|
||||
"- **R**:本盘起运、年数、双主、小运起点与方向六步都已定出,仅作参考",
|
||||
"- **V**:Vimshottari 提供主要时间框架;Narayana 的当前分支因双体系比较未闭环,保留为条件性窗口",
|
||||
"- **S**:支持一面是第7宫 SAV 30 属强、宫内木星落陷阱有取消",
|
||||
];
|
||||
|
||||
const numbers = (text: string) => (text.match(/\d+(?:[.\-:]\d+)*/g) ?? []).sort();
|
||||
|
||||
test("hedges, vote and closure wording and 激活 leave the basis; content and every number stay", () => {
|
||||
const shown = withoutBasisNoise(ROUND27.join("\n"));
|
||||
assert.deepEqual(basisNoiseSpans(shown), []);
|
||||
assert.deepEqual(numbers(shown), numbers(ROUND27.join("\n")));
|
||||
const lines = shown.split("\n");
|
||||
assert.equal(lines[0], "- **年盘**:2026-08-08 至 2027-08-08 年盘,年主木星,Mudda 土星 2026-11-10 至 2027-01-07;本轮只解释事业。");
|
||||
assert.equal(lines[1], "- **N**:Narayana 主运天秤(第 4 宫,2018-08-08 至 2028-08-07),与 Vimshottari 的小运主星是同一个盘面事实");
|
||||
assert.equal(lines[2], "- **N2**:子运金牛(第 11 宫,2026-02-06 至 2026-12-08)");
|
||||
assert.equal(lines[3], "- **T**:木星与土星同时关联到第 10 宫的区段为 2027-02-05 至 2027-05-20(D1 层)");
|
||||
assert.equal(lines[4], "- **R**:本盘起运、年数、双主、小运起点与方向六步都已定出");
|
||||
assert.equal(lines[5], "- **V**:Vimshottari 提供主要时间框架");
|
||||
// The typo is the model's (no table writes 「阱」); the display separates the two words.
|
||||
assert.equal(lines[6], "- **S**:支持一面是第7宫 SAV 30 属强、宫内木星落陷,有取消");
|
||||
});
|
||||
|
||||
test("a line that is only a hedge goes; the product footer is not basis text", () => {
|
||||
assert.equal(withoutBasisNoise("- **Y**:年盘取数本身只作参考\n- **Z**:月亮在第 4 宫"), "- **Z**:月亮在第 4 宫");
|
||||
assert.equal(withoutBasisNoise("木星在第 9 宫,强度 6.2"), "木星在第 9 宫,强度 6.2");
|
||||
});
|
||||
|
||||
test("item titles lose the hedge and vote wording but keep the technique name", () => {
|
||||
assert.equal(basisTitleWithoutNoise("年运只作结构参考"), "年运");
|
||||
assert.equal(basisTitleWithoutNoise("KP 与整宫并列、不额外计票"), "KP 与整宫并列");
|
||||
assert.equal(basisTitleWithoutNoise("Narayana 只作条件性参考"), "Narayana");
|
||||
assert.equal(basisTitleWithoutNoise("只作参考"), "只作参考");
|
||||
const items = parseJudgmentBasisItems("- **年运只作结构参考**:Tajika 2026-08-05 至 2027-08-05,仅作参考。(只是可能,C)");
|
||||
assert.equal(items?.[0]?.title, "年运");
|
||||
assert.deepEqual(items?.[0]?.facts.map((fact) => fact.text), ["Tajika 2026-08-05 至 2027-08-05"]);
|
||||
});
|
||||
|
||||
test("the chat check sends these basis lines to the rewrite round, and the table result is clean", () => {
|
||||
const answer = `结论。\n\n## 判断依据\n\n${ROUND27[1]}\n${ROUND27[3]}\n`;
|
||||
const scan = scanInternalWords(answer, {});
|
||||
assert.deepEqual(scan.units.map((unit) => unit.tokens), [["不另计一票"], ["共同激活"]]);
|
||||
const prompt = internalWordRepairPrompt(scan.units);
|
||||
assert.match(prompt, /不另计一票:后台的规则口吻/);
|
||||
assert.match(prompt, /共同激活:不写「激活」一类的说法/);
|
||||
assert.match(prompt, /「只作参考」一类的保留话、计票和闭环这类规则口吻都去掉/);
|
||||
assert.equal(scrubInternalWords(ROUND27[4]!), "- **R**:本盘起运、年数、双主、小运起点与方向六步都已定出");
|
||||
});
|
||||
|
||||
test("the chat table no longer writes 「只作参考」 back into a basis line", () => {
|
||||
assert.doesNotMatch(scrubInternalWords("KP 为参数敏感,换宫制会变"), /参考/);
|
||||
assert.doesNotMatch(scrubInternalWords("各步已定,但按来源只为参考"), /参考/);
|
||||
});
|
||||
@@ -96,10 +96,12 @@ test("the table uses existing wording, drops what carries nothing, and leaves re
|
||||
assert.equal(scrubInternalWords("各步已定,但卡上 chat_use 为 single_system_candidate,不据此写成双体系确认。"), "各步已定,但参考,不据此写成两种方法一致。");
|
||||
assert.equal(scrubInternalWords("为单体系候选(`chat_use` = single_system_candidate),只作条件性窗口"), "为参考,只作条件性窗口");
|
||||
assert.equal(scrubInternalWords("起运比较这一步有分歧(seed 为 disputed),属单体系候选"), "起运比较这一步有分歧(起运比较有分歧),属参考");
|
||||
assert.equal(scrubInternalWords("各步虽已定,但按卡上状态只作为单体系候选,不据此加强应期"), "各步虽已定,但只作为参考,不据此加强应期");
|
||||
// BUG-2137 原值「各步虽已定,但只作为参考,不据此加强应期」/ 新值「不据此加强应期」/ 原因:「只作为参考」是表自己写回的保留话,「各步虽已定」是后台口吻(复测第二十七轮),都不给读者看
|
||||
assert.equal(scrubInternalWords("各步虽已定,但按卡上状态只作为单体系候选,不据此加强应期"), "不据此加强应期");
|
||||
assert.equal(scrubInternalWords("Tajika 年盘只在第一目标集上验证过"), "Tajika 年盘只在一部分案例上验证过");
|
||||
// BUG-2011 (staging 复测第三轮): no long wording dropped into another sentence, no trailing separator.
|
||||
assert.equal(scrubInternalWords("年盘为参数敏感层,只作结构参考"), "年盘为参考层,只作结构参考");
|
||||
// BUG-2137 原值「年盘为参考层,只作结构参考」/ 新值「年盘为参考层」/ 原因:「只作结构参考」是保留话(报告 BUG-2101 已去掉同一变体)
|
||||
assert.equal(scrubInternalWords("年盘为参数敏感层,只作结构参考"), "年盘为参考层");
|
||||
// BUG-2025 (复测第六轮):判断依据里的「卡上」、英文星名和星座、「随参数翻转」;引号和英文句子里的不动。
|
||||
assert.equal(scrubInternalWords("Narayana 主运 Libra(Venus)2018-08-08 至 2028-08-07;卡上各步均已定"), "Narayana 主运天秤(金星)2018-08-08 至 2028-08-07;各步均已定");
|
||||
assert.equal(scrubInternalWords("宫主金星落本命第 2 宫,与 Mercury、Rahu 同宫"), "宫主金星落本命第 2 宫,与水星、罗睺同宫");
|
||||
@@ -115,16 +117,19 @@ test("the table uses existing wording, drops what carries nothing, and leaves re
|
||||
assert.equal(scrubInternalWords("被土星相位照(受冲来源把它记在第 1 宫,作用为压力)"), "被土星相位照(受冲记在第 1 宫,作用为压力)");
|
||||
assert.equal(scrubInternalWords("第 10 宫主火星落第 4 宫,为本盘 yogakaraka;"), "第 10 宫主火星落第 4 宫,为本盘特别有利的星");
|
||||
// BUG-2039 (复测第九轮)
|
||||
assert.equal(scrubInternalWords("各步已定,但按来源只为参考"), "各步已定,但只作参考");
|
||||
// BUG-2137 原值「各步已定,但只作参考」/ 新值「各步已定」/ 原因:表不再往「判断依据」里写「只作参考」,留下的「但」一并去掉
|
||||
assert.equal(scrubInternalWords("各步已定,但按来源只为参考"), "各步已定");
|
||||
// BUG-2041 (复测第十轮):写作说明整句去掉;格局状态、其余口吻;英文回答不动。
|
||||
assert.equal(scrubInternalWords("- **事业阻力**:A10 位于摩羯,其主星土星位于本命第 9 宫,这几处只读作这条线要多花的力气,不翻成行业或台前幕后。"), "- **事业阻力**:A10 位于摩羯,其主星土星位于本命第 9 宫。");
|
||||
assert.equal(scrubInternalWords("Shadbala 上木星 6.61 Rupa,达标与否随未定参数(Chesta Bala、Drik Bala 口径)翻转,因此正文不提它的力量高低"), "Shadbala 上木星 6.61 Rupa,是否达到最低线随算法设置会变");
|
||||
assert.equal(scrubInternalWords("KP 为参数敏感,换宫制会变;受冲账上记了两项;未见分盘边界临界项"), "KP 只作参考,换宫制会变;受冲里记了两项;出生时间前后几分钟不影响这一条");
|
||||
assert.equal(scrubInternalWords("KP 为参数敏感,换宫制会变;受冲账上记了两项;未见分盘边界临界项"), "KP 的结果会随算法设置变化,换宫制会变;受冲里记了两项;出生时间前后几分钟不影响这一条");
|
||||
// BUG-2137 原值「KP 只作参考,……」/ 新值「KP 的结果会随算法设置变化,……」/ 原因:「为参数敏感」不再换成保留话,改用报告 BUG-2130 的说法
|
||||
const english = "You will feel stretched.\n\n## 判断依据\n\n- **Work load**: transit Saturn enters Aries (your 10th house) on 2027-05-20, while Jupiter stays in Leo. (depends on birth time within minutes)\n- **Money**: the 2nd lord Sun sits in the 1st house with Mercury and Rahu nearby, and Venus rules the 11th house.";
|
||||
assert.deepEqual(scanInternalWords(english).units, [], "an English answer keeps its English words");
|
||||
// 卡片和证据包的分析句不查这些(只查判断依据)。
|
||||
assert.deepEqual(findInternalWords("依赖项不在这张卡上;与 Mercury 同宫"), []);
|
||||
assert.equal(scrubInternalWords("Vimshottari 提供主要时间框架,Narayana 的当前分支按来源版各步配置计算,保留为条件性窗口,暂不作为双体系确认"), "Vimshottari 提供主要时间框架,Narayana 的当前分支,保留为条件性窗口");
|
||||
assert.equal(scrubInternalWords("Vimshottari 提供主要时间框架,Narayana 的当前分支按来源版各步配置计算,保留为条件性窗口,暂不作为双体系确认"), "Vimshottari 提供主要时间框架,Narayana 的当前分支");
|
||||
// BUG-2137 原值「…,Narayana 的当前分支,保留为条件性窗口」/ 新值去掉「保留为条件性窗口」/ 原因:后台口吻(占星师 11-19 分层规则,复测第二十七轮)
|
||||
assert.equal(scrubInternalWords("不计),net_result=strength_comparison_required,强弱待裁"), "不计),待定,强弱待裁");
|
||||
assert.equal(scrubInternalWords("第 10 宫 SAV 33(极吉,sav_strength 强),且被土星照"), "第 10 宫 SAV 33(极吉,强),且被土星照");
|
||||
assert.equal(scrubInternalWords("被太阳、火星照(aspected_by: Sun, Mars);火星为 DK"), "被太阳、火星照(太阳, 火星);火星为 DK");
|
||||
|
||||
Reference in New Issue
Block a user