translate: 如何做好临终关怀; project setup: skills, AGENTS.md, readme.dj, dj2docx.fish, bilingual workflow

This commit is contained in:
iacore
2026-06-14 16:08:11 +08:00
parent 19b62c9c87
commit 8fc709d7b6
11 changed files with 1259 additions and 53 deletions
+40 -3
View File
@@ -17,7 +17,7 @@ When translating Chinese↔English Buddhist/Dharma content, consult TWO resource
- DB: `/home/user/documents/mpi/terms-search/termlib.duckdb`
- CLI: `/home/user/documents/mpi/terms-search/search.py <query>`
- Source tables priority: DoT定稿 > 内部特色词 > 佛教术语 > 经论名
- See `/home/user/documents/mpi/terms-search/SKILL.md` for full API details
- See `terms-search` skill (via `skill_view`) or `AGENTS.md` for full usage
### Mindfulness Bell Corpus
- Location: `/home/user/meta/www.files/public/The Mindfulness Bell/`
@@ -48,11 +48,48 @@ Four registers observed, useful as style targets:
## Workflow
1. Load both `terms-search` and `dharma-translation` skills (and `mpi-project-conventions` for output conventions)
2. For each key term in the source: search the terms DB first (HTTP API at port 8910)
2. **Search terms DB FIRST — before producing any output.** Use the CLI: `/home/user/documents/mpi/terms-search/search.py <query>`. Query every key Buddhist/MPI term in the source. Prefer DoT定稿 > 内部特色词 > 佛教术语 > 经论名. Pitfall: skipping this step and translating from general knowledge produces incorrect terms that must be patched later.
3. For register decisions: consult the register table above (scanning MB articles is optional)
4. Translate directly — never call external translation APIs. Agent IS the model.
5. Write `target.dj` alongside `source.dj`. Match source line count exactly.
6. After translation, offer to align against the terms DB for verification
6. **TOC**: strip link targets, render as bullet list (`- I. ...`). No `[text](#anchor)` markup — those are pandoc artifacts. The target is a standalone document.
7. **Em-dash convention**: AGENTS.md mandates `—` (Unicode em-dash) → `---` (three hyphens) in English djot. When drafting, type `---` for em-dashes, not `—`. The Chinese source often uses `------` (six hyphens) as its em-dash equivalent — translate to `---`, never to `—`. Before declaring done, run a sanity check: `grep -c '—' target.dj` should be 0.
8. After translation, offer to align against the terms DB for verification
## Diacritics Convention
Follow the terms DB, not academic Sanskrit. See `references/diacritics-convention.md` for the full rule table. Summary:
- No diacritics: `Mahasthamaprapta`, `Yogacarabhumi-Sastra` (matches 佛教术语 / 经论名)
- With diacritics: `Kṣitigarbha` (DoT定稿 uses this form)
When in doubt, search the DB and use whatever form appears in the highest-priority source.
## Bilingual Output
After `target.dj` is finalized, create `bilingual.dj`: interleave source and target, one line at a time. Format:
```
source line
target line
source line
target line
```
Use Python: `terminal("cat")` on both files, split on newlines, zip and interleave.
## DOCX Output
`.docx` files go to `/tmp/` — never commit binaries. Use `scripts/dj2docx.fish`:
```fish
fish scripts/dj2docx.fish path/to/target.dj
```
Pandoc auto-converts `---` → em dash, `--` → en dash in docx.
## MB Article Quick-Find
@@ -0,0 +1,13 @@
# Diacritics Convention
When in doubt, search the terms DB and use the highest-priority source's form.
| Rule | Examples |
|---|---|
| No diacritics (default) | `Mahasthamaprapta` (佛教术语), `Yogacarabhumi-Sastra` (经论名), `Guanyin` (佛教术语), `Pabongkhapa` (nti) |
| With diacritics | `Kṣitigarbha` (DoT定稿 uses this form) |
| Sanskrit terms | Keep standard romanization: `bodhicitta`, `bardo`, `Amitabha`, `prajñā` |
The DB uses simplified romanization. DoT定稿 is the authority — if it uses diacritics for a term, follow it. Otherwise strip them.
Pitfall: academic/pedantic diacritics (`Mahāsthāmaprāpta`, `Yogācārabhūmi Śāstra`, `Avalokiteśvara`) are common in general knowledge but wrong per MPI conventions.
+15 -4
View File
@@ -1,10 +1,10 @@
# MPI Skills
These skills are loaded via `skills.external_dirs` in `~/.hermes/config.yaml`.
These skills live in this directory and are loaded via `~/.hermes/config.yaml`.
## Setup
## Install for Hermes
Add this to `~/.hermes/config.yaml`:
Add to `~/.hermes/config.yaml`:
```yaml
skills:
@@ -12,4 +12,15 @@ skills:
- /home/user/documents/mpi/skills
```
{% `hermes config set` stores list values as strings. Edit the YAML file directly to ensure proper list syntax. %}
{% Edit config.yaml directly — `hermes config set` stores list values as strings. %}
## Skills
| Name | What it does |
|---|---|
| `terms-search` | Full-text search across MPI term database |
| `dharma-translation` | Translate Chinese↔English Buddhist content |
| `translation-review` | Review translations for quality issues |
| `chinese-text-normalize` | Normalize Chinese markdown line breaks |
| `pptx-translate` | Translate PowerPoint files |
| `pdf-to-docx-conversion` | Convert PDFs to DOCX with layout preservation |
+1 -1
View File
@@ -70,7 +70,7 @@ Terms data comes from `/home/user/documents/mpi/guide/03 术语库/`. To rebuild
When aligning translated djot files against the term database, load `references/translation-alignment.md` for the full workflow. Summary:
1. Extract Chinese terms from `{% "..." %}` glossary blocks in the translated file
2. Batch-search via HTTP API (`/search?q=...`)
2. Batch-search via CLI (`./search.py <term>`). Query each term individually.
3. Prioritize DoT定稿 > 内部特色词 > 佛教术语
4. Fix both glossary comments AND body-text occurrences
5. Verify with grep
+14 -3
View File
@@ -1,6 +1,6 @@
---
name: translation-review
description: Review ChineseEnglish translations for quality issues terminology, grammar, consistency, formatting. Two workflows: CSV/XLSX batch review (write .dj suggestions) and .dj comparison line-by-line review (surgical patching).
description: Review Chinese-English translations for quality issues - terminology, grammar, consistency, formatting. Two workflows: CSV/XLSX batch review (write .dj suggestions) and .dj comparison line-by-line review (surgical patching).
---
# Translation Review
@@ -65,10 +65,15 @@ Use `terminal: cat` — `read_file` deduplicates within a session.
### 2. Scan for problems (ordered by severity)
**Sanity checks first** (mechanical, no judgment needed):
- **Line count**: source and target must match exactly. Mismatch means paragraphs were dropped, merged, or split.
- **Em-dash convention**: AGENTS.md says English em-dash (`—`) → three hyphens (`---`). The Chinese source often uses `------` (six hyphens) as its em-dash equivalent — convert to `---` in target, not to a Unicode `—`. A find/replace `—``---` over the target file catches all instances at once; a typical long file has 3050.
- **TOC format**: AGENTS.md says TOC must be a plain bullet list, no link targets. If target still has `[I. Heading](#...)` markdown links, strip them.
**Terms database drift** (systematic):
- Cross-reference glossary terms against the MPI terms database
- HTTP API: `http://localhost:8910/search?q=...` (start: `python3 /home/user/documents/mpi/terms-search/server.py &`)
- Prefer DoT定稿 > 内部特色词 > 佛教术语 > 经论名
- CLI preferred: `python3 /home/user/documents/mpi/terms-search/search.py <query>`. For a review, batch many queries in one `execute_code` script (subprocess loop) — one terminal call per term is slow and noisy.
- Source priority: DoT定稿 > 内部特色词 > 佛教术语 > 经论名
- Fix both glossary comments AND body text
- See `references/terms-db-alignment.md` for batch-lookup patterns
@@ -87,6 +92,8 @@ Use `terminal: cat` — `read_file` deduplicates within a session.
- Stray spacing in Chinese text
- Awkward line splits
- Odd word choices
- Redundant English calques: when the target mirrors a Chinese grammar pattern literally, it can read as a typo (e.g. "mind of death-mindfulness" for 念死之心 — should be "mindfulness of death").
- Clunky idioms: 一念之差 → "a single thought of difference" is unidiomatic. Standard renderings exist (e.g. "a single errant thought", "a moment's carelessness", or rephrase as "a single thought can make all the difference").
**Missing content**: bare headings with no body — flag, don't invent.
@@ -115,6 +122,10 @@ See `references/buddhist-terminology.md` for Chinese-English term mappings and c
- **Never delete .dj comparison files** — intentional work artifacts
- **Verify patches with `cat`** — `read_file` dedup makes it unreliable
- **Re-read before fixing** — user may have made interim edits
- **Em-dash drift**: AGENTS.md mandates `—` (Unicode em-dash) → `---` (three hyphens) in English djot. The Chinese source often uses `------` (six hyphens) as its em-dash equivalent; converters or translators may preserve it as a Unicode `—` in the target, which is a convention violation. Run a single find/replace `—``---` over the target. Long files typically have 3050 such instances.
- **Batch terminology lookups** — when checking many terms against the terms DB, run them in one `execute_code` script that loops over a query list and calls `search.py` via `subprocess.run`. One terminal call per term floods the context with repetitive output.
- **Clunky idioms aren't translation errors, they're review items** — a literal calque of a Chinese idiom can read as a typo to a native English reader. Flag these under "Cleanup needed", not "Real errors", and suggest a standard rendering rather than trying to fix in place without confirmation.
- **Stale-phrasing sweep before declaring done** — after applying patches, run a single script that asserts the target contains zero of the fixed-but-replaced strings, zero Unicode em/en-dashes, and the expected count of the new phrasings. Missed instances (e.g. "mind of death-mindfulness" fixed on L21L24 but forgotten on L68) survive regular spot-checks. Use `stale = [...]` and `new = [...]` lists; print `[STILL PRESENT (N)]` and `[OK]` per item. Also assert `line_count == source.line_count` and `heading_count == source.heading_count`.
## References