fix: close final general guard grammar gaps

This commit is contained in:
Jesse_Chen
2026-07-21 10:22:05 +08:00
parent 1b3fdcd641
commit 4f16a9be1d
2 changed files with 16 additions and 5 deletions
+10 -5
View File
@@ -25,7 +25,7 @@ const chineseOwnedChartSubjectPattern = new RegExp(
"iu",
);
const chineseUserHasChartPattern = new RegExp(
String.raw`(?:你|您)\s*(?:为|是|有)\s*(?:一(?:个|颗)\s*)?${chineseChartObjectSource}`,
String.raw`(?:你|您)\s*(?:为|是|有|拥有)\s*(?:一(?:个|颗)\s*)?${chineseChartObjectSource}`,
"iu",
);
const chinesePersonalChartContextPattern = /(?:(?:|)|(?:|)(?:)?(?:?||||)|(?:|)(?:)?(?:?||||)(?:|)?)/iu;
@@ -42,8 +42,8 @@ const englishOwnedChartSubjectPattern = new RegExp(
String.raw`\b(?:your|the\s+user(?:'s)?)\s+(?:personal\s+)?${englishChartObjectSource}\b`,
"iu",
);
const englishUserHasChartPattern = new RegExp(
String.raw`\byou\s+have\s+(?:an?\s+)?(?:${englishZodiacSignSource}\s+rising|${englishChartObjectSource})\b`,
const englishUserIsOrHasChartPattern = new RegExp(
String.raw`\byou\s+(?:are|have)\s+(?:an?\s+)?(?:${englishZodiacSignSource}\s+(?:rising|ascendant)|${englishChartObjectSource})\b`,
"iu",
);
const englishPersonalChartContextPattern = /\b(?:for\s+you|(?:in|from|based\s+on|according\s+to)\s+your\s+(?:natal\s+|birth\s+)?chart)\b/iu;
@@ -54,6 +54,10 @@ const englishChartAddressesUserPattern = new RegExp(
const chineseEducationalFramePattern = /^(?:(?:|)(?:)?(?:|)|(?:|)(?:)?(?:)?(?:)?)[\s,:]*/iu;
const chineseAboutGeneralMeaningPattern = /^\s*(?:|)(?:)?\s*(.+?(?:|))$/iu;
const chineseChartMetaReferencePattern = new RegExp(
String.raw`${chineseChartObjectSource}\s*(?:(?:的\s*)?一般问题|方面的问题|问题(?:的\s*)?提问者|(?:的\s*)?提问者)`,
"giu",
);
const englishEducationalFramePattern = /^(?:your\s+question\s+is|you\s+asked\s+about)\s*/iu;
function normalizeClaimClause(clause: string) {
@@ -64,7 +68,8 @@ function normalizeClaimClause(clause: string) {
.trim();
normalized = normalized
.replace(chineseEducationalFramePattern, "")
.replace(englishEducationalFramePattern, "");
.replace(englishEducationalFramePattern, "")
.replace(chineseChartMetaReferencePattern, "咨询问题");
const aboutGeneralMeaning = chineseAboutGeneralMeaningPattern.exec(normalized);
return aboutGeneralMeaning?.[1] ?? normalized;
}
@@ -78,7 +83,7 @@ function isPersonalChartConclusion(clause: string) {
&& chineseChartObjectPattern.test(normalized)
&& chineseChartPredicatePattern.test(normalized);
const englishStructure = (englishOwnedChartSubjectPattern.test(normalized)
|| englishUserHasChartPattern.test(normalized)
|| englishUserIsOrHasChartPattern.test(normalized)
|| englishPersonalChartContextPattern.test(normalized)
|| englishChartAddressesUserPattern.test(normalized))
&& englishChartObjectPattern.test(normalized)
@@ -115,6 +115,9 @@ test("general mode rejects personalized chart predicates beyond possessive place
"你是巨蟹上升。",
"您有一个巨蟹上升。",
"You have Cancer rising.",
"You are Cancer rising.",
"You have a Cancer ascendant.",
"你拥有巨蟹上升。",
"In your chart, Venus occupies the seventh house.",
"For you, Venus falls in the seventh house.",
];
@@ -134,6 +137,9 @@ test("general mode preserves educational chart questions and general knowledge",
"关于你的第七宫的一般含义。",
"你是一个正在研究第七宫的学生。",
"你可以先了解第七宫的一般概念。",
"你有第七宫的一般问题。",
"你有金星方面的问题,可以继续问。",
"你是第七宫问题的提问者。",
"第七宫在占星概念中常与关系相关。",
"Your question is the general meaning of the seventh house.",
"You asked about the seventh house.",