Compare commits

...
Author SHA1 Message Date
jesse-uxandGrok (agent loop) 830e5d0267 test(report): expect parenthesized karaka names in the full-data table
The Chinese full-data body prints karaka names with parentheses after the glued-phrase pass. The BPHS order test still expected the KARAKA_CN literals and failed the full pytest run. Expect translate_zh_glued_phrases of KARAKA_CN instead of editing KARAKA_CN.

Pytest of the karaka file, the six report contract files, and privacy markers: 154 passed. tsc exit 0. lint 0 errors, 125 warnings.

Co-Authored-By: Grok (agent loop)
2026-10-13 15:55:56 +08:00
jesse-ux 7242648e45 merge origin/staging into the report translation fix 2026-10-13 15:20:55 +08:00
jesse-uxandGrok (agent loop) a295afa40f fix(report): draw charts in the full-data body and clean Chinese residue
New reports draw one north-Indian chart for each ready divisional in the body, so the trailing duplicate section drops. Chinese full-data prose no longer glues English onto Han or leaves listed, background, or native. The birth table starts with the ascendant. The D9 same-sign column says yes or no.

Self-test: tsc exit 0; npm run lint exit 0 (0 errors, 125 existing warnings); three frontend test files 39 pass, 0 fail, 0 cancelled; pytest test_report_chart_blank_columns.py 16 passed; seven related report files 88 passed, exit 0; privacy markers 63 passed.

Co-Authored-By: Grok (agent loop)
2026-10-13 14:02:26 +08:00
15 changed files with 3490 additions and 11 deletions
+7
View File
@@ -1,5 +1,12 @@
# 印度占星 Skill 更新日志
## 2026-10-13 — 新报告正文画出分盘,中文更干净,上升行和同位列能读懂(待合入 staging)
- 重新生成的报告里,「本命与分盘北印度图盘」每张有数据的盘下面有一张北印度图。同一张盘只画一次。报告最末不再重复「分盘核对」。旧报告打开仍是当时保存的正文。
- 中文报告正文去掉 listed、background、native、Custom condition met 这类英文,也不再把中文和英文粘成一个词。括号里的星宿、瑜伽名保留。
- 「本命盘行星原始位置」第一行是上升,星宿和 pada 有值。尊贵状态写「不适用」。没有可填的格子与其它空格一样写「未列」。
- 星盘页 D9 表的「同位」列:同座写「是」,不同座写「否」。其它分盘仍没有这一列。Skill 版本不变(BUG-1312~1315)。
## 2026-10-12 — 设置里的岁差说明改对:新开的生时校正也跟着设置走(已合入 staging)
- 设置页换岁差时的说明原来写「生时校正目前仍固定按 Raman」,与实际相反。改为:之后的咨询、报告、星盘库、每日星语和新开的生时校正会按新岁差算;已经开始的那次校正仍按开始时的岁差。Skill 版本不变(BUG-1310)。
+59
View File
@@ -17615,3 +17615,62 @@
- 相关记录:BUG-511、BUG-1309。
- 复发自:无。
- 修复版本:已部署 staging `586561eb`(2026-10-12 核对:health gitCommit / apiGitCommit=586561eb、`requiredMigrationsPresent` true,`/login` 200,未登录 `/api/account` 401;合并后 npm test 5025 条、失败 24 逐名同 `798e15ef` 基线)。Claude 直接执行,产品 10-12 授权。
## BUG-1312 | 中文完整数据报告正文仍有英文功能词,并与汉字粘在一起
- 状态:fixed-pending-verify(只对新生成的报告生效;真机清单 `docs/testing/report-translation-gaps-20261013.md` 未走,不标 resolved)
- 首次发现 / 最近更新:2026-10-13 / 2026-10-13
- 来源:issue #53。任务书在 `941b06c19` 重跑虚构日盘:附录之前英文功能词 218 处、汉字与英文粘连 14 处。
- 现象:中文报告里出现 listed、background、native、Custom condition met,以及「木星Jupiter…」这种中英粘在一起的字。星宿、瑜伽名放在括号里是允许的。
- 根因:中文完整数据版是在英文原文上做短词替换。短词先换会把长句切碎;有的格子本身就是英文枚举,中文版原样印出。瑜伽组合在中文路径仍优先取了英文组合句。行星中文名已经带英文,庙旺又紧挨着拼上去,中间没有空格。
- 修复:中文路径先整句、长词,再短词。宫主状态换成「当前运行 / 背景」,listed 换成「已列出」,native 换成「本命」,自定义条件换成「满足自定义条件」。中文瑜伽用中文组合句。不改行星中文名本身,也不改八分法引擎文件;报告层把粘在一起的方法名改成带空格的读法。残留门只数附录之前的正文,图盘围栏不计入:汉字与至少 3 个拉丁字母直接粘连为 0,功能词 of/in/the/and/by/from/with/listed/background/native/condition/met/satisfied/occupied 为 0。括号里的梵文和表头缩写 SAV、BAV、KP、D1–D60 不在这两项里。
- 验证:故意写入「木星Jupiterexalted」时残留门为 fail。虚构日盘、虚构夜盘、一张公开名人盘(爱因斯坦)的中文完整数据版都是粘连 0、功能词 0。`tests/test_report_chart_blank_columns.py` 16 通过。打回第 1 次:报告星位表已印成「灵魂星(AK)」这类带括号的名字,`test_reader_report_karaka_table_is_in_bphs_order` 仍按 `KARAKA_CN` 原字面值比对,已改为经 `translate_zh_glued_phrases` 后再比对。`KARAKA_CN` 未改。
- 防复发:`_pl9_markdown_hygiene_receipt(language="zh")` 把上述两项写成违规。
- 相关记录:BUG-1313、BUG-1314。
- 复发自:无。
- 修复版本:分支 `codex/report-translation-gaps-20261013`,尚未合入 staging。
## BUG-1313 | 完整数据版「本命与分盘北印度图盘」只有空标题,正文不画图
- 状态:fixed-pending-verify(旧报告正文不变,须重新生成;真机清单未走,不标 resolved)
- 首次发现 / 最近更新:2026-10-13 / 2026-10-13
- 来源:issue #53。
- 现象:该节是一列盘名,没有北印度方形图。报告末尾因此仍出现第二遍「分盘核对」。
- 根因:完整数据版只写空的小标题,不写图盘围栏。10-07 个人报告改用完整数据版之后,BUG-1203「正文画全分盘、末尾整段消失」的前提没了。当时的测试只用读者版样例,没拦住这次切换。
- 修复:这一节里每张有星座可画的盘写一张北印度图,同一编号只画一次。去掉与九分盘重复的第二张,以及画不出来的空宫位标题。逆行跟本命。中英标题都有。末尾「分盘核对」仍用原来的去重,不新做折叠。旧样例保留,用来锁住「旧正文仍显示分盘核对」。
- 验证:虚构日盘中英两版该节围栏可解析、版式为北印度、编号不重复、没有空标题。新的完整数据样例覆盖计算图全部编号时,末尾核对段渲染为空。前端相关测试 39 通过、0 失败、0 取消。
- 防复发:`tests/test_report_chart_blank_columns.py::test_full_data_chart_section_draws_each_ready_chart_once`;`frontend/tests/report-calculation-charts.test.tsx` 用真实引擎输出的新样例锁住末尾消失,旧样例仍锁住旧正文保留该节。
- 相关记录:BUG-1203、BUG-1312。
- 复发自:BUG-1203(完整数据版切换后正文无围栏;当时只用读者版样例)。
- 修复版本:分支 `codex/report-translation-gaps-20261013`,尚未合入 staging。
## BUG-1314 | 报告「本命盘行星原始位置」没有上升行
- 状态:fixed-pending-verify(真机清单未走,不标 resolved)
- 首次发现 / 最近更新:2026-10-13 / 2026-10-13
- 来源:issue #53。星盘页上升行已由 BUG-1201 补上星宿、宿主、pada;报告这张表没有。
- 现象:报告本命位置表从九曜开始,看不到上升的星座、度数、星宿和 pada。
- 根因:表只遍历九曜。上升点上的星宿字段已经算好,报告没用。
- 修复:中文表首行写「上升」,英文写 Ascendant。宫位为 1,星宿用「中文(梵文)」,pada 与星宿计算一致。主星表上升行的尊贵状态写「不适用」(英文 not applicable),星宿主用星宿主星。不给上升另造庙旺。
- 偏离:任务书要求逆行和速度两格写横杠。完整数据版原有的空格清理会把单独的横杠格改成「未列」(英文 not listed),和别的空格子一样。主星表里相邻的两个空格,后一格仍会留下一条横杠。尊贵状态保持「不适用」。测试不要求必须看见那条横杠。
- 验证:虚构日盘上升行的星宿、pada、宫位 1、星宿主与星宿计算一致;尊贵状态为「不适用」。同文件既有用例仍通过(16 通过)。
- 防复发:`test_birth_position_table_starts_with_the_ascendant`。
- 相关记录:BUG-1201、BUG-1099。
- 复发自:无。
- 修复版本:分支 `codex/report-translation-gaps-20261013`,尚未合入 staging。
## BUG-1315 | 星盘页 D9「同位」列几乎全是横杠,读起来像没算
- 状态:fixed-pending-verify(真机清单第 7 步未走,不标 resolved)
- 首次发现 / 最近更新:2026-10-13 / 2026-10-13
- 来源:issue #53。庙旺列已由 BUG-1202 修好;这一列不是。
- 现象:D9 表「同位」列里,不是同座的行星显示「—」。大多数行星都不是同座,整列几乎都是横杠。
- 根因:横杠表示「不是同位」,和「这一格没数据」长得一样。
- 决策:按任务书 D2 的推荐执行。同座写「是」,不同座写「否」,表头仍是「同位」。不改 BUG-1099:不是 D9 就不显示这一列;旧缓存没有能力声明时整列隐藏。
- 修复:行星行和上升行都改成「是 / 否」。`frontend/DESIGN.md` 同步。缺星宿、庙旺、宫位时别处仍用横杠,本轮没改。
- 验证:`frontend/tests/chart-varga-table.test.tsx` 断言三栏——原值:同位格「同位」、非同位「—」;新值:「是」「否」;原因:BUG-1315。另加「非同位行显示否」和「非 D9 没有同位列」。`chart-page-hook` 里表头「同位」的检查仍在。前端这三份测试 39 通过、0 失败、0 取消。`tsc --noEmit` 退出码 0。
- 防复发:同上前端测试。
- 相关记录:BUG-1099、BUG-1202。
- 复发自:无。
- 修复版本:分支 `codex/report-translation-gaps-20261013`,尚未合入 staging。
@@ -0,0 +1,50 @@
# PROGRESS · 报告翻译缺口 · 2026-10-13
任务书:`docs/tasks/TASK-report-translation-gaps-20261013.md`。Issue #53。执行分支 `codex/report-translation-gaps-20261013`,基于当时的 `origin/staging` `05f880053`(任务书基线 `941b06c19` 的后代)。D1、D2 按任务书推荐执行:图盘并入正文,同位列写「是 / 否」。不需要另请拍板。
## 状态一览
| 任务 | 状态 | 说明 |
| --- | --- | --- |
| T1 正文图盘 | 完成 | 有星座可画的盘各一张北印度图,编号不重复;去掉重复的九分盘和画不出的空宫位标题 |
| T2 中文残留 | 完成 | 虚构日盘、虚构夜盘、公开名人盘(爱因斯坦)粘连 0、功能词 0。基线是粘连 14、功能词 218。未让步 |
| T3 上升行 | 完成 | 位置表首行是上升;主星表尊贵状态「不适用」 |
| T4 同位列 | 完成 | D9 写「是 / 否」,表头仍是「同位」;非 D9 无此列 |
| T5 记录 | 完成 | BUG-1312~1315、本文件、CHANGELOG。真机清单在基线上已有,步骤与实现一致,未改写 |
## 偏离
- 上升行的逆行、速度,任务书写横杠。完整数据版原有清理会把单独的横杠格改成「未列」(英文 not listed),与其它空格相同。主星表相邻两个空格里,后一格仍留下一条横杠。尊贵状态仍是「不适用」。测试不把那条横杠当成必须出现。
- `next build` 与首屏 gzip 未跑。任务书 §8 与执行提示把全量前端测试和 Python 快速门留给验收侧;本轮自测不含这两项,不写成通过。
- `test:db` 未跑:没有改数据库。
- 真机清单 `docs/testing/report-translation-gaps-20261013.md` 已在分支基线上,八步与当前行为一致,本轮没有改它,也没有往 `BLOCKED.md` 加浏览器项。
## 自测
| 检查 | 命令 | 结果 |
| --- | --- | --- |
| 类型 | `frontend\node_modules\.bin\tsc --noEmit -p frontend` | 退出码 0 |
| 规范 | 在 `frontend` 下 `npm run lint` | 退出码 0;0 error,125 条既有 warning |
| 改到的前端测试 | `node node_modules/tsx/dist/cli.mjs --test tests/chart-varga-table.test.tsx tests/chart-page-hook.test.ts tests/report-calculation-charts.test.tsx` | 39 通过,0 失败,0 取消 |
| 图盘 / 上升 / 残留 | `.venv\Scripts\python -m pytest tests/test_report_chart_blank_columns.py -q --tb=line` | 16 通过,退出码 0 |
| 英文版、附录、读者版、星盘表合同、完整数据修复、图盘围栏 | `.venv\Scripts\python -m pytest tests/test_report_english_edition.py tests/test_reader_appendix_language.py tests/test_reader_appendix_shared_rules.py tests/test_report_reader_main.py tests/test_chart_page_vedic_tables_contract.py tests/test_report_full_data_fix.py tests/test_report_chart_block.py -q --tb=line` | 88 通过,退出码 0 |
| 隐私标记 | `.venv\Scripts\python -m pytest tests/test_repo_privacy_markers.py -q --tb=line` | 63 通过,退出码 0 |
未跑:前端全量 `npm test`、Python 快速门、`npm run test:db`、`next build`。
## 第 1 次打回(2026-10-13)
修复单:`docs/tasks/TASK-report-translation-gaps-fix-20261013.md`。报告四项本身不改。
- 修复单要求变基到当时的最新 `origin/staging`(`d79f42b04ba225e5be39d8567a7fdd38223e19fe`)。本地变基后的文件内容与现在相同,但这台机器不允许改写已经推送过的分支。因此改为把这份 staging 合并进本分支:测试版是本分支的祖先,推送不用改写历史。报告生成和星位中文原名没有再动。
- 只改 `tests/test_chara_karaka_8_bphs_order.py` 里报告星位表那一条。期望值改成 `translate_zh_glued_phrases(KARAKA_CN[role])`,也就是「灵魂星(AK)」这一类。`scripts/jaimini.py` 的 `KARAKA_CN` 没改。
- 检索 `tests` 与 `frontend/tests`:按 `KARAKA_CN` 原字面值断言完整数据版报告正文的,只有这一条。`frontend/tests/fixtures/report-reader-main-fictional-zh-pair.json` 未改。咨询金样和旧阅读版夹具里的「灵魂星AK」不是这份报告正文,未改。
- `tests/test_prashna_sphuta_review_result_validator.py` 里基线已有的失败未动。
| 检查 | 命令 | 结果 |
| --- | --- | --- |
| 星位表、§8 六个文件、隐私标记 | `.venv\Scripts\python -m pytest tests/test_chara_karaka_8_bphs_order.py tests/test_report_chart_blank_columns.py tests/test_report_english_edition.py tests/test_reader_appendix_language.py tests/test_reader_appendix_shared_rules.py tests/test_report_reader_main.py tests/test_chart_page_vedic_tables_contract.py tests/test_repo_privacy_markers.py -q --tb=line` | 154 通过,退出码 0 |
| 类型检查 | `frontend\node_modules\.bin\tsc --noEmit -p frontend` | 退出码 0 |
| 前端 lint | `npm run lint --prefix frontend` | 0 error,125 warning |
未跑:前端全量 `npm test`、Python 快速门、`npm run test:db`(本轮没动数据库)、`next build`。
+1 -1
View File
@@ -1183,7 +1183,7 @@ D40 / D45 / D60 的表格上方,出生时间不是「已校正」时多一句
| 盘型 | 列 | 说明 |
| --- | --- | --- |
| 本命 | 上面八列 | 不变(与基线渲染逐字节相同) |
| D2–D60 | 行星 · 分盘星座(度°分′)· 宫位 · 本命星座 · 庙旺;仅 D9 再有同位 | 宫位从该分盘上升数;庙旺是引擎给的十档(入旺 / 本垣 / 入庙 / 极友 / 入友 / 中性 / 入敌 / 极敌 / 落陷 / 落陷取消),措辞与本命「状态」列一字不差(2026-10-03,BUG-1202,取代原先「入旺 / 自宫 / 落陷,其余—」的三档);旧缓存没有引擎等级时整列不显示,页面不自算;上升此格「不适用」。2026-09-29 收口:仅 D9 的 D1↔D9 同座比较显示为同位,其他分盘不显示此列。两列各由服务端能力声明控制,缺声明保守隐藏,不以是否命中推断支持性。**没有星宿 / 宿主 / 足**:那是本命经度的属性。逆行在行星格后标「逆」(分盘不改顺逆)。首行是分盘上升 |
| D2–D60 | 行星 · 分盘星座(度°分′)· 宫位 · 本命星座 · 庙旺;仅 D9 再有同位 | 宫位从该分盘上升数;庙旺是引擎给的十档(入旺 / 本垣 / 入庙 / 极友 / 入友 / 中性 / 入敌 / 极敌 / 落陷 / 落陷取消),措辞与本命「状态」列一字不差(2026-10-03,BUG-1202,取代原先「入旺 / 自宫 / 落陷,其余—」的三档);旧缓存没有引擎等级时整列不显示,页面不自算;上升此格「不适用」。2026-09-29 收口:仅 D9 的 D1↔D9 同座比较显示此列,其他分盘不显示。2026-10-13:同座写「是」,不同座写「否」,表头仍是「同位」(不再用横杠,避免看成没算)。两列各由服务端能力声明控制,缺声明保守隐藏,不以是否命中推断支持性。**没有星宿 / 宿主 / 足**:那是本命经度的属性。逆行在行星格后标「逆」(分盘不改顺逆)。首行是分盘上升 |
| 月亮盘 | 本命八列 | 宫位从月亮所在星座数;表头「月亮盘 · 以月亮所在星座(X)为第 1 宫」;盘上「As」画在本命上升落的那一宫(`VedicChartSvg` 的 `ascendantHouse`,其它盘默认 1 宫不变) |
| Bhava | 行星 · 黄道经度 · 星座宫 · Bhava 宫 · 换宫;另一张「宫 · 宫头 · 起点(sandhi)」12 行 | Sripati。换宫的行用 `--color-selected` 浅底。拿不到真实 MC 时这一栏走失败句,不画等宫(BUG-1077) |
| 行运 | 行星 · 今天的位置 · 速度 · 落本命 · 本命同星 | 表头写计算时刻「行运 · YYYY-MM-DD 12:00(时区)」,上方一句「以本命上升为第 1 宫,放的是这一天中午的行星位置。岁差和交点与本命相同。」 |
@@ -152,7 +152,7 @@ function VargaRow({ row, supportsDignity, supportsVargottama }: { row: ChartView
<td>{row.house}宫</td>
<td>{row.natalSignLabel}</td>
{supportsDignity && <td className="chart-page-planet-mid">{row.dignity ? VARGA_DIGNITY_LABEL[row.dignity] : "—"}</td>}
{supportsVargottama && <td className="chart-page-planet-mid">{row.vargottama ? "同位" : "—"}</td>}
{supportsVargottama && <td className="chart-page-planet-mid">{row.vargottama ? "是" : "否"}</td>}
</tr>
);
}
@@ -167,7 +167,7 @@ function VargaAscendantRow({ row, supportsDignity, supportsVargottama }: { row:
<td>1宫</td>
<td>{row.natalSignLabel}</td>
{supportsDignity && <td className="chart-page-planet-mid">不适用</td>}
{supportsVargottama && <td className="chart-page-planet-mid">{row.vargottama ? "同位" : "—"}</td>}
{supportsVargottama && <td className="chart-page-planet-mid">{row.vargottama ? "是" : "否"}</td>}
</tr>
);
}
+16 -1
View File
@@ -138,7 +138,11 @@ test("divisional rows carry engine dignity and vargottama, and drop nakshatra co
for (const column of ["行星", "分盘星座", "宫位", "本命星座", "庙旺", "同位"]) assert.match(header, new RegExp(`>${column}<`));
assert.doesNotMatch(header, /星宿|宿主|pada/);
// Same wording as the D1 status column (BUG-1202), friendship levels included.
assert.match(row(markup, "土星"), />入庙\(Own Sign\)<[\s\S]*>同位</);
// 原值:同位行星单元格是「同位」,非同位是「—」
// 新值:同位写「是」,非同位写「否」
// 原因:BUG-1315。横杠和「没数据」长得一样,表头仍叫「同位」
assert.match(row(markup, "土星"), />入庙\(Own Sign\)<[\s\S]*>是</);
assert.match(row(markup, "太阳"), />否</);
assert.match(row(markup, "太阳"), />落陷\(Debilitated\)</);
assert.match(row(markup, "月亮"), />入友\(Friendly Sign\)</);
assert.match(row(markup, "火星"), />中性\(Neutral\)</);
@@ -168,6 +172,17 @@ function assertColumns(markup: string, dignity: boolean, vargottama: boolean) {
for (const [, cells] of rows) assert.equal((cells!.match(/<(?:th|td)\b/g) ?? []).length, count);
}
test("a non-vargottama row says 否 and a non-D9 chart has no same-sign column", async () => {
const view = await vargaView();
const d9 = render(view, "D9");
assert.match(row(d9, "太阳"), />否</);
const d10 = view.vedic.vargas.find((item) => item.id === "D10")!;
assert.equal(d10.supportsVargottama, false);
const markup = tableMarkup(d10);
assert.doesNotMatch(markup, />同位</);
assert.doesNotMatch(markup, />否</);
});
test("server capabilities retain dignity for every Dn and vargottama only for D9", async () => {
const view = await vargaView();
for (const varga of view.vedic.vargas) {
File diff suppressed because one or more lines are too long
@@ -36,6 +36,19 @@ test("an older body without chart fences keeps its charts, without the moved cav
assert.doesNotMatch(markup, /出生时间敏感/);
});
test("a full-data body that fences every calculation chart drops the trailing section", () => {
const fullData = JSON.parse(readFileSync(new URL("./fixtures/report-full-data-chart-fences.json", import.meta.url), "utf8"));
const fullCharts = assembleLongformCharts(fullData.packet, "ev-cover-longform");
const drawn = fencedReportChartIds(fullData.markdown);
assert.ok(fullCharts.length > 0);
for (const chart of fullCharts) assert.ok(drawn.has(chart.id), chart.id);
assert.equal(renderToStaticMarkup(React.createElement(ReportCalculationCharts, {
charts: fullCharts,
markdown: fullData.markdown,
language: "zh",
})), "");
});
test("the page and the export skip the same charts", () => {
const first = /```jyotish-chart\n[\s\S]*?```/.exec(fixture.markdown)![0];
const drawn = [...fencedReportChartIds(first)];
+34 -1
View File
@@ -107,7 +107,13 @@ def _sanitize_pl9_ai_density_markdown(markdown: str, title: str = "印度占星
strip_han_plural_s,
)
text = _sanitize_pl9_public_markdown(markdown)
try:
from pl9_language_terms import translate_zh_glued_phrases
except ModuleNotFoundError: # pragma: no cover - package import compatibility
from scripts.pl9_language_terms import translate_zh_glued_phrases
# Whole phrases and glued planet+dignity tokens before shorter word swaps.
# Chapters appended after the parity strip still pass through here.
text = translate_zh_glued_phrases(_sanitize_pl9_public_markdown(markdown))
replacements = {
"# PL9 对标主册": f"# {title}",
"出生资料与图盘(PL9 p1-p17)": "出生资料与图盘",
@@ -1264,6 +1270,27 @@ def _sanitize_pl9_ai_density_markdown_en(markdown: str, title: str = "Vedic Astr
# Body residue (BUG-1312). Parenthetical Sanskrit names (nakshatra, yoga,
# Dasha) and header abbreviations (SAV, BAV, KP, D1-D60) are separated from
# Han by parentheses or spaces, so they are not "glued". They are not function
# words. Chart fences are structured payload and are not part of the prose count.
_ZH_GLUE_RE = re.compile(r"[\u4e00-\u9fff][A-Za-z]{3,}|[A-Za-z]{3,}[\u4e00-\u9fff]")
_ZH_FUNCTION_WORD_RE = re.compile(
r"(?<![A-Za-z])(?:of|in|the|and|by|from|with|listed|background|native|condition|met|satisfied|occupied)(?![A-Za-z])",
re.IGNORECASE,
)
_ZH_CHART_FENCE_RE = re.compile(r"```jyotish-chart\n.*?\n```", re.DOTALL)
def _zh_body_residue(markdown: str) -> dict[str, int]:
body = (markdown or "").split("## 结构化资料附录", 1)[0]
body = _ZH_CHART_FENCE_RE.sub("", body)
return {
"glued_latin": len(_ZH_GLUE_RE.findall(body)),
"function_words": len(_ZH_FUNCTION_WORD_RE.findall(body)),
}
def _pl9_markdown_hygiene_receipt(markdown: str, *, language: str) -> dict[str, Any]:
"""Check the Markdown before rendering user-facing PDF."""
@@ -1327,6 +1354,12 @@ def _pl9_markdown_hygiene_receipt(markdown: str, *, language: str) -> dict[str,
chinese_chars = len(re.findall(r"[\u4e00-\u9fff]", markdown))
if chinese_chars:
violations.append(f"chinese_characters:{chinese_chars}")
if language == 'zh':
residue = _zh_body_residue(markdown)
if residue["glued_latin"]:
violations.append(f"glued_latin:{residue['glued_latin']}")
if residue["function_words"]:
violations.append(f"function_words:{residue['function_words']}")
language_receipt = language_quality_receipt(markdown, language=language)
violations.extend(language_receipt.get("violations") or [])
orphan_lines = orphan_separator_lines(markdown)
+5 -2
View File
@@ -864,11 +864,14 @@ def build_yoga_interpretation_pack(
if name in seen:
continue
seen.add(name)
combination = str(raw.get("combination_en") or raw.get("combination") or raw.get("reason") or "")
if language == "en":
combination = str(raw.get("combination_en") or raw.get("name") or combination)
combination = str(raw.get("combination_en") or raw.get("name") or raw.get("combination") or "")
if re.search(r"[\u4e00-\u9fff]", combination):
combination = "combination text is not listed separately"
else:
# Chinese pages keep the Chinese combination. combination_en is the
# English twin and must not leak into the Chinese report.
combination = str(raw.get("combination") or raw.get("reason") or "")
planets = [str(item) for item in _list(raw.get("planets"))]
overlap = sorted(set(planets) & set(active))
if language == "zh":
+120
View File
@@ -11,6 +11,126 @@ import re
from typing import Any
# Bilingual planet tokens from yoga combination text, longest first.
# Dignity is glued on with no space ("木星Jupiterexalted"), so the long form
# has to be translated before the short planet name.
_BILINGUAL_PLANETS = (
("南交点Ketu", "南交点"),
("北交点Rahu", "北交点"),
("水星Mercury", "水星"),
("木星Jupiter", "木星"),
("金星Venus", "金星"),
("土星Saturn", "土星"),
("火星Mars", "火星"),
("月亮Moon", "月亮"),
("太阳Sun", "太阳"),
)
_GLUED_DIGNITY = {
"exalted": "入旺",
"debilitated": "落陷",
"moolatrikona": "本垣",
"own": "入庙",
"strong": "强",
}
_BILINGUAL_PLANET_RE = re.compile(
"(" + "|".join(re.escape(raw) for raw, _public in _BILINGUAL_PLANETS) + ")"
+ "(exalted|debilitated|moolatrikona|own|strong)?"
)
_BILINGUAL_PLANET_ZH = dict(_BILINGUAL_PLANETS)
# Whole formation sentences and status tokens. Longer phrases stay above the
# short-word glossary so "of" / "in" are not left stuck to Chinese.
_ZH_FORMATION_PHRASES = (
(
"| Bhava Number | Bhava Arambha / House beginning | Bhava Madhya / Middle of House | Bhava Antya / House ending |",
"| 宫位编号 | 宫位起点 | 宫位中点 | 宫位终点 |",
),
(
"Lord of sign occupied in navamsa by 2nd/5th/11th lord, exalted and joins the 9th lord",
"第2、第5或第11宫主在九分盘所落星座的宫主入旺,并与第9宫主会合",
),
(
"Lord of navamsa occupied by 4th lord in 12th",
"第4宫主在九分盘所落星座的宫主位于第12宫",
),
("Learned, eloquent, wealthy from knowledge", "有学识,善表达,学问带来资源"),
("Loss or destruction of property/house", "房屋或产业有损耗"),
(
"Lagna lord, his dispositor, the latter's dispositor in rasi and navamsa, all in kendras/trines/exaltation",
"上升主星、它的定位星,以及定位星的定位星,在本命盘和九分盘都落在角宫、三方宫或入旺",
),
("Fulfills all desires, great king, supreme wealth", "愿望容易得到回应,传统上对应较高的地位与丰厚资源"),
("Eloquent, skilled in debate, good communicator", "善表达,辩论清楚,沟通能力强"),
("Enjoyment of food, pleasure in dining, hospitality", "饮食安稳,待客从容"),
("Courage, initiative, status and practical drive", "有行动力,做事务实"),
("Fear of deception, theft; deceptive nature", "容易担心受骗或失物,需要再核对事实"),
(
"Lagna malefic/Gulika in trine OR Gulika with Kendra/Trine lords OR L1 with Rahu/Sat/Ket",
"凶星或吉利伽在三方宫,或吉利伽与角宫、三方宫主同在,或上升主与罗睺、土星、计都同在",
),
("或BVR精神扰动变体", "或(BVR)精神扰动变体"),
("very_rare", "极少"),
("Not supplied by source", "源数据未提供"),
("Crux of Vedic Astrology", "《吠陀占星精要》"),
("Viparita Raja Yoga", "颠倒王者格"),
("Dhana Yoga", "财富瑜伽"),
("Raj Yoga", "王者格"),
("Custom condition met", "满足自定义条件"),
("custom condition satisfied", "满足自定义条件"),
("自定义条件满足", "满足自定义条件"),
("hemmed in by malefics", "被凶星夹制"),
("hemmed in by benefics", "被吉星夹制"),
("occupied in navamsa", "在九分盘所落"),
("occupied in navamsha", "在九分盘所落"),
("Mutual aspect", "互照"),
("mutual aspect", "互照"),
("drig_rath_aspect_sequence_v1", "Drig 相位顺序 v1"),
("Ashtakavarga八分法(BPHS/PVR书例校准v2.1)", "Ashtakavarga 八分法(BPHS / PVR 书例校准 v2.1)"),
("Sade Sati阶段框架", "Sade Sati 阶段框架"),
("灵魂星AK", "灵魂星(AK)"),
("事业星AmK", "事业星(AmK)"),
("兄弟星BK", "兄弟星(BK)"),
("母亲星MK", "母亲星(MK)"),
("子女星PK", "子女星(PK)"),
("障碍星GK", "障碍星(GK)"),
("配偶星DK", "配偶星(DK)"),
("父亲星PiK", "父亲星(PiK)"),
)
def translate_zh_glued_phrases(text: str) -> str:
"""Translate whole bilingual tokens before any shorter English word."""
if not text:
return text
def planet(match: re.Match) -> str:
name = _BILINGUAL_PLANET_ZH[match.group(1)]
dignity = _GLUED_DIGNITY.get(match.group(2) or "", "")
return name + dignity
text = _BILINGUAL_PLANET_RE.sub(planet, text)
for raw, public in _ZH_FORMATION_PHRASES:
text = text.replace(raw, public)
# House-lord combinations are printed as H6_Lord(Venus) in H12. Translate
# the whole pattern before the short word "in" is left beside Chinese.
text = re.sub(
r"H(\d+)_Lord\(([^)]+)\) in H(\d+)",
r"第\1宫主(\2)在第\3宫",
text,
)
text = re.sub(r"H(\d+)_Lord\(([^)]+)\)", r"第\1宫主(\2)", text)
# Status tokens printed as bare English words. Longer phrases above already
# consumed "not listed" / "Custom condition met", so these are the leftovers.
for raw, public in (
("listed", "已列出"),
("background", "背景"),
("native", "本命"),
):
text = re.sub(rf"(?<![A-Za-z]){raw}(?![A-Za-z])", public, text)
return text
def replace_natural_language_term(text: str, raw: str, public: str) -> str:
"""Replace one glossary term in prose only.
+23
View File
@@ -35,6 +35,29 @@ _PHRASES: dict[str, str] = {
"特殊上升与派生点补充": "Special Lagnas and Points (supplement)",
"敏感点与特殊落点": "Sensitive Points and Special Placements",
"本命与分盘北印度图盘": "Natal and Divisional Charts (North Indian)",
# Chart fences in the parity volume. The Chinese label is the key; the
# English edition looks these up instead of keeping a second title list.
"D1 本命盘": "D1 natal chart",
"月亮盘": "Moon chart",
"D2 财富分盘": "D2 wealth chart",
"D3 手足分盘": "D3 siblings chart",
"D4 居所分盘": "D4 home chart",
"D5 声望分盘": "D5 reputation chart",
"D6 压力分盘": "D6 pressure chart",
"D7 子女分盘": "D7 children chart",
"D8 变化分盘": "D8 change chart",
"D9 九分盘": "D9 navamsha",
"D10 事业分盘": "D10 career chart",
"D11 收益分盘": "D11 gains chart",
"D12 父母分盘": "D12 parents chart",
"D16 享受分盘": "D16 comforts chart",
"D20 灵修分盘": "D20 practice chart",
"D24 学习分盘": "D24 learning chart",
"D27 内在分盘": "D27 inner chart",
"D30 困难分盘": "D30 difficulty chart",
"D40 母系分盘": "D40 maternal chart",
"D45 父系分盘": "D45 paternal chart",
"D60 深层分盘": "D60 deep chart",
"分盘对出生时间敏感,原始计算供核对,不单独增加结论的确定性。":
"Divisional charts are sensitive to birth time. The raw calculations are here for checking and do not by themselves make a conclusion more certain.",
" 数值位置表": " Position Table",
+188 -3
View File
@@ -111,7 +111,11 @@ def _pl9_report_language(packet: dict) -> str:
def _strip_pl9_user_engineering_markers(markdown: str) -> str:
"""Remove internal audit/profile vocabulary from user-facing report text."""
text = markdown
try:
from scripts.pl9_language_terms import translate_zh_glued_phrases
except ModuleNotFoundError: # pragma: no cover - direct scripts/ execution
from pl9_language_terms import translate_zh_glued_phrases
text = translate_zh_glued_phrases(markdown)
replacements = {
"parameter_sensitive / unverified": "参考",
"parameter_sensitive": "参考",
@@ -481,6 +485,149 @@ def _render_pl9_user_markdown(packet: dict) -> str:
return cleaned
# Drawable charts in the parity "north Indian charts" section. Bhava (Sripati)
# has no chart id (its numbers stay in the Sripati table). Navamsha is not
# listed again: it is the same id as D9. English titles live in
# pl9_reader_english_terms, keyed by these Chinese labels.
_PARITY_CHARTS = (
("D1", "D1 本命盘", "d1"),
("MOON", "月亮盘", "moon"),
("D2", "D2 财富分盘", ("D2_Hora", "D2")),
("D3", "D3 手足分盘", ("D3_Drekkana", "D3")),
("D4", "D4 居所分盘", ("D4_Turyamsa", "D4_Chaturthamsa", "D4")),
("D5", "D5 声望分盘", ("D5_Panchamsa", "D5")),
("D6", "D6 压力分盘", ("D6_Shashthamsa", "D6")),
("D7", "D7 子女分盘", ("D7_Saptamsa", "D7")),
("D8", "D8 变化分盘", ("D8_Ashtamsa", "D8")),
("D9", "D9 九分盘", ("D9_Navamsa", "D9")),
("D10", "D10 事业分盘", ("D10_Dasamsa", "D10")),
("D11", "D11 收益分盘", ("D11_Rudramsa", "D11")),
("D12", "D12 父母分盘", ("D12_Dwadashamsa", "D12_Dvadasamsa", "D12")),
("D16", "D16 享受分盘", ("D16_Shodasamsa", "D16")),
("D20", "D20 灵修分盘", ("D20_Vimsamsa", "D20")),
("D24", "D24 学习分盘", ("D24_Siddhamsa", "D24_Chaturvimsamsa", "D24")),
("D27", "D27 内在分盘", ("D27_Bhamsa", "D27")),
("D30", "D30 困难分盘", ("D30_Trimsamsa", "D30")),
("D40", "D40 母系分盘", ("D40_Khavedamsa", "D40")),
("D45", "D45 父系分盘", ("D45_Akshavedamsa", "D45")),
("D60", "D60 深层分盘", ("D60_Shashtyamsa", "D60_Shashtiamsa", "D60")),
)
def _parity_chart_title(zh: str, language: str) -> str:
if language != "en":
return zh
try:
from scripts.pl9_reader_english_terms import PHRASES_EN
except ModuleNotFoundError: # pragma: no cover - direct scripts/ execution
from pl9_reader_english_terms import PHRASES_EN
return dict(PHRASES_EN).get(zh, zh)
def _parity_chart_source(kind, core_chart, worksheets, divisional, varga_full):
if kind == "d1":
planets = core_chart.get("planets") if isinstance(core_chart.get("planets"), dict) else {}
ascendant = core_chart.get("ascendant") if isinstance(core_chart.get("ascendant"), dict) else {}
return planets, ascendant
if kind == "moon":
d1_sheet = worksheets.get("d1_rasi_bhava") if isinstance(worksheets.get("d1_rasi_bhava"), dict) else {}
moon = d1_sheet.get("moon_chart") if isinstance(d1_sheet.get("moon_chart"), dict) else {}
if not moon and isinstance(divisional.get("moon_chart"), dict):
moon = divisional["moon_chart"]
raw = moon.get("raw") if isinstance(moon.get("raw"), dict) else {}
if not raw and isinstance(moon.get("data"), dict):
raw = moon["data"]
if not raw:
raw = moon
if isinstance(raw.get("raw"), dict):
raw = raw["raw"]
ascendant = {}
for key in ("Ascendant", "ascendant", "Asc"):
if isinstance(raw.get(key), dict):
ascendant = raw[key]
break
planets = raw.get("planets") if isinstance(raw.get("planets"), dict) else {}
return planets, ascendant
chart = {}
for key in kind:
candidate = varga_full.get(key) if isinstance(varga_full, dict) else None
if isinstance(candidate, dict) and candidate:
chart = candidate
break
ascendant = {}
for key in ("Ascendant", "ascendant", "Asc"):
if isinstance(chart.get(key), dict):
ascendant = chart[key]
break
return chart, ascendant
def _append_parity_chart_fences(lines, *, language, core_chart, worksheets, divisional, varga_full) -> None:
"""One north-Indian fence per chart that has a sign to draw. No empty heading."""
try:
from scripts.report_chart_block import PLANET_ORDER, build_chart_block
except ModuleNotFoundError: # pragma: no cover - direct scripts/ execution
from report_chart_block import PLANET_ORDER, build_chart_block
natal = core_chart.get("planets") if isinstance(core_chart.get("planets"), dict) else {}
retrograde = {
name: bool(row.get("retrograde")) if isinstance(row, dict) else False
for name in PLANET_ORDER
for row in [natal.get(name)]
}
seen: set[str] = set()
for chart_id, title_zh, kind in _PARITY_CHARTS:
if chart_id in seen:
continue
positions, ascendant = _parity_chart_source(kind, core_chart, worksheets, divisional, varga_full)
title = _parity_chart_title(title_zh, language)
try:
block = build_chart_block(chart_id, title, positions, ascendant, retrograde)
except (TypeError, ValueError):
continue
seen.add(chart_id)
lines.extend([f"##### {title}", "", block, ""])
def _ascendant_report_fields(asc: dict) -> dict:
"""Longitude, nakshatra and lords for the report's ascendant row. No new dignity."""
longitude = None
for key in ("lon", "longitude", "degree_raw"):
value = asc.get(key)
if isinstance(value, (int, float)):
longitude = float(value) % 360.0
break
if longitude is None:
sign = asc.get("sign")
degree = asc.get("degree_in_sign")
if not isinstance(degree, (int, float)):
degree = asc.get("degree")
signs = globals().get("SIGNS") or []
if sign in signs and isinstance(degree, (int, float)):
longitude = signs.index(sign) * 30.0 + float(degree)
fields = {}
if longitude is not None:
try:
from scripts.jyotish_engine import _nakshatra_fields
except ModuleNotFoundError: # pragma: no cover - direct scripts/ execution
from jyotish_engine import _nakshatra_fields
fields = _nakshatra_fields(longitude)
degree = asc.get("degree_in_sign")
if not isinstance(degree, (int, float)):
degree = asc.get("degree")
pada = fields.get("nakshatra_pada") if fields else None
if pada is None:
pada = asc.get("nakshatra_pada") or asc.get("pada")
return {
"sign": asc.get("sign"),
"degree": degree,
"longitude": longitude,
"nakshatra": fields.get("nakshatra") or asc.get("nakshatra"),
"pada": pada,
"nakshatra_lord": fields.get("nakshatra_lord") or asc.get("nakshatra_lord"),
"sign_lord": asc.get("lord") or asc.get("rasi_lord"),
}
def render_pl9_parity_markdown(packet: dict) -> str:
"""Render only PL9 page-family material admitted to the parity main volume."""
_bind_engine_symbols()
@@ -544,6 +691,18 @@ def render_pl9_parity_markdown(packet: dict) -> str:
elif isinstance(value, (list, tuple)):
value = ';'.join(str(item) for item in value if item not in (None, '', [], {}))
text = str(value if value not in (None, '') else '-').replace('\n', ' ').strip()
if _lang != 'en':
# Whole status tokens. Longer phrases are handled in the glossary
# before these short words, so a half-translated fragment is not
# cleaned up by deleting letters here.
text = {
'active': '当前运行',
'background': '背景',
'listed': '已列出',
'native': '本命',
'Custom condition met': '满足自定义条件',
'custom condition satisfied': '满足自定义条件',
}.get(text, text)
return text.replace('|', '/')
def _brief(items, limit=2) -> str:
@@ -668,6 +827,10 @@ def render_pl9_parity_markdown(packet: dict) -> str:
def _public_status_note(value) -> str:
zh_mapping = {
'partial_verified': '已生成',
'listed': '已列出',
'active': '当前运行',
'background': '背景',
'native': '本命',
'parameter_sensitive': '参数敏感',
'blocked': '需补资料',
'verified': '已核验',
@@ -856,6 +1019,14 @@ def render_pl9_parity_markdown(packet: dict) -> str:
'| Planet | R/C | Sign | Degree | Longitude | House | Nakshatra | Pada | Speed |',
'|--------|-----|------|--------|-----------|-------|-----------|------|-------|',
])
ascendant = _dict(core_chart.get('ascendant'))
if ascendant:
info = _ascendant_report_fields(ascendant)
asc_label = 'Ascendant' if _lang == 'en' else '上升'
lines.append(
f"| {_cell(asc_label)} | - | {_cell(_token(info['sign']))} | {_cell(_degree(info['degree']))} | "
f"{_cell(_degree(info['longitude']))} | 1 | {_cell(info['nakshatra'])} | {_cell(info['pada'])} | - |"
)
for planet in ('Sun', 'Moon', 'Mars', 'Mercury', 'Jupiter', 'Venus', 'Saturn', 'Rahu', 'Ketu'):
row = _dict(planets.get(planet))
if not row:
@@ -875,6 +1046,14 @@ def render_pl9_parity_markdown(packet: dict) -> str:
'| 行星 | 星座主 | 星宿主 | 分主 | 分分主 | 尊贵状态 | 力量比 |',
'|------|--------|--------|------|--------|----------|--------|',
])
if ascendant:
info = _ascendant_report_fields(ascendant)
asc_label = 'Ascendant' if _lang == 'en' else '上升'
dignity = 'not applicable' if _lang == 'en' else '不适用'
lines.append(
f"| {_cell(asc_label)} | {_cell(_token(info['sign_lord']))} | {_cell(_token(info['nakshatra_lord']))} | "
f"- | - | {_cell(dignity)} | - |"
)
for planet in ('Sun', 'Moon', 'Mars', 'Mercury', 'Jupiter', 'Venus', 'Saturn', 'Rahu', 'Ketu'):
row = _dict(planets.get(planet))
if not row:
@@ -1078,8 +1257,14 @@ def render_pl9_parity_markdown(packet: dict) -> str:
ready_natal_specs = [spec for spec in natal_specs if spec[2]]
if ready_natal_specs:
lines.extend(['### p6-p17 本命与分盘北印度图盘', '', '分盘对出生时间敏感,原始计算供核对,不单独增加结论的确定性。', ''])
for page, label, _ready in ready_natal_specs:
lines.extend([f'##### p{page} · {label}', ''])
_append_parity_chart_fences(
lines,
language=_lang,
core_chart=core_chart,
worksheets=worksheets,
divisional=divisional,
varga_full=varga_full,
)
# The original PL9 charts are visual, but their sign placements are
# still part of the visible evidence. Keep the chart drawing and add
# a compact numeric transcription so an AI reader can recover the
+7 -1
View File
@@ -62,6 +62,7 @@ def test_reader_report_karaka_table_is_in_bphs_order() -> None:
import copy
from scripts.jaimini import KARAKA_CN
from scripts.pl9_language_terms import translate_zh_glued_phrases
from scripts.pl9_reader_export import _pl9_export_markdown_for_edition
from tests.test_report_english_edition import CASES, _packet
@@ -70,4 +71,9 @@ def test_reader_report_karaka_table_is_in_bphs_order() -> None:
lines = markdown.splitlines()
start = next(i for i, line in enumerate(lines) if line.startswith("### Jaimini Karaka"))
rows = [line for line in lines[start + 1:start + 14] if line.startswith("| ") and "星" in line.split("|")[1]]
assert [row.split("|")[1].strip() for row in rows] == [KARAKA_CN[role] for role in BPHS_8]
# 原值:[KARAKA_CN[role] for role in BPHS_8](灵魂星AK、事业星AmK、兄弟星BK、母亲星MK、父亲星PiK、子女星PK、障碍星GK、配偶星DK)
# 新值:[translate_zh_glued_phrases(KARAKA_CN[role]) for role in BPHS_8](灵魂星(AK)、事业星(AmK)、兄弟星(BK)、母亲星(MK)、父亲星(PiK)、子女星(PK)、障碍星(GK)、配偶星(DK))
# 原因:完整数据版正文会给这八个星位名的缩写加括号,避免三字母缩写被粘连检查判中。KARAKA_CN 仍是原字面值,咨询和星盘页继续用它。
assert [row.split("|")[1].strip() for row in rows] == [
translate_zh_glued_phrases(KARAKA_CN[role]) for role in BPHS_8
]
+108
View File
@@ -150,6 +150,114 @@ def test_ashtakavarga_house_table_never_labels_the_total_as_sav(editions) -> Non
assert row[5].isdigit()
_CALCULATION_CHART_IDS = {
"D1", "D2", "D3", "D4", "D7", "D9", "D10", "D11", "D12",
"D16", "D20", "D24", "D27", "D30", "D40", "D60",
}
def _section_until_next_h2(markdown: str, heading: str) -> str:
start = markdown.index(heading)
lines = [heading]
for line in markdown[start + len(heading):].splitlines():
if line.startswith("## "):
break
lines.append(line)
return "\n".join(lines)
def test_full_data_chart_section_draws_each_ready_chart_once(editions) -> None:
from scripts.report_chart_block import FENCE_RE
zh, en, _packet = editions
for markdown, heading in (
(zh, "### 本命与分盘北印度图盘"),
(en, "### Natal and Divisional North Indian Charts"),
):
section = _section_until_next_h2(markdown, heading)
blocks = []
for match in FENCE_RE.finditer(section):
block = json.loads(match.group(1))
assert block["layout"] == "north"
blocks.append(block)
ids = [block["id"] for block in blocks]
assert ids
assert len(ids) == len(set(ids))
assert _CALCULATION_CHART_IDS <= set(ids)
assert "MOON" in ids
assert not re.search(r"(?m)^##### .+\n\n+##### ", section)
assert not re.search(r"(?m)^##### .*Bhava", section)
assert "##### Navamsha" not in section and "##### p7 · Navamsha" not in section
def _heading_table(markdown: str, heading: str) -> list[list[str]]:
"""Like _table_after, but the lord table is a #### heading, not ###."""
lines = markdown.splitlines()
start = next(i for i, line in enumerate(lines) if line.startswith("#") and heading in line)
rows = []
for line in lines[start + 1:]:
if line.startswith("#") or (rows and not line.startswith("|")):
break
if line.startswith("|") and not set(line) <= set("|- "):
rows.append([cell.strip() for cell in line.strip("|").split("|")])
return rows
def test_birth_position_table_starts_with_the_ascendant(editions) -> None:
zh, en, packet = editions
asc = packet["core_chart"]["ascendant"]
longitude = asc.get("lon") if isinstance(asc.get("lon"), (int, float)) else asc.get("degree_raw")
fields = _nakshatra_fields(float(longitude))
lord_zh = {
"Sun": "太阳", "Moon": "月亮", "Mars": "火星", "Mercury": "水星",
"Jupiter": "木星", "Venus": "金星", "Saturn": "土星",
"Rahu": "北交点", "Ketu": "南交点",
}
zh_rows = _heading_table(zh, "行星原始位置")
assert zh_rows[1][0] == "上升"
assert fields["nakshatra"] in zh_rows[1][6]
assert zh_rows[1][7] == str(fields["nakshatra_pada"])
assert zh_rows[1][5] == "1"
lords = _heading_table(zh, "行星主星与状态")
assert lords[1][0] == "上升"
assert lords[1][5] == "不适用"
assert lords[1][2] in {fields["nakshatra_lord"], lord_zh.get(fields["nakshatra_lord"])}
en_rows = _heading_table(en, "Planetary Raw Positions")
assert en_rows[1][0] in {"Ascendant", "Lagna", "上升"}
assert fields["nakshatra"] in en_rows[1][6]
assert en_rows[1][7] == str(fields["nakshatra_pada"])
def test_zh_hygiene_rejects_glued_english(editions) -> None:
from scripts.pl9_full_data_export import _pl9_markdown_hygiene_receipt, _zh_body_residue
injected = _pl9_markdown_hygiene_receipt("木星Jupiterexalted在巨蟹座\n", language="zh")
assert injected["status"] == "fail"
assert any(str(item).startswith("glued_latin:") for item in injected["violations"])
residue = _zh_body_residue(editions[0])
assert residue == {"glued_latin": 0, "function_words": 0}
def test_zh_hygiene_is_clean_on_night_and_a_public_chart() -> None:
from scripts.pl9_full_data_export import _zh_body_residue
# Public birth used by tests/smoke_test_runner.py. Not a private user.
public = {
**CASES["day"],
"name": "Albert Einstein",
"year": 1879,
"month": 3,
"day": 14,
"hour": 11,
"minute": 30,
"lat": 48.4,
"lon": 9.98,
"tz": 0.89,
"age": 76,
}
for case in (CASES["night"], public):
packet = _packet(case)
markdown = _pl9_export_markdown_for_edition(copy.deepcopy(packet), "full_data")
assert _zh_body_residue(markdown) == {"glued_latin": 0, "function_words": 0}
def test_chart_section_carries_the_divisional_caveat(editions) -> None:
zh, en, _ = editions
assert re.search(r"### 本命与分盘北印度图盘\n\n" + re.escape(CAVEAT_ZH) + r"\n", zh)