From b20fcb9c3c0484b3a41458eb3061a0f3347949a3 Mon Sep 17 00:00:00 2001 From: xiaji Date: Tue, 16 Jun 2026 23:35:58 +0800 Subject: [PATCH] =?UTF-8?q?docs(readme):=20=E5=90=8C=E6=AD=A5=E8=AF=91?= =?UTF-8?q?=E6=96=87=E6=B8=85=E6=B4=97=E5=8A=9F=E8=83=BD=20+=20Phase=201.8?= =?UTF-8?q?=20=E8=B7=AF=E7=BA=BF=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 关键特性列表新增 🧹 译文清洗(源头防御 + 批量脚本) - LLM 智能增强章节补 '译文清洗(text_clean)' 小节: 源头防御 + 批量清洗两层防护 + 4 条清洗规则 - 排版任务描述里的 '加粗' 改为 '层次'(加粗 = ** 脏数据来源) - 运维工具表格加 clean_translations.py 用法 - 路线图加 Phase 1.8(2026-06-16) 纯文档改动,服务器前端不需要 rebuild --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f7e7081..7acfdb6 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ - 📌 **收藏 + 关键词订阅**:用户级书签,服务端定时按关键词命中推送(预留 Telegram 通道) - 📊 **管理看板**:源健康度 / 翻译配额 / LLM 状态,全部可视化 - 🔍 **智能搜索建议** *(新)*:`GET /api/v1/search/suggestions?q=prefix` 实时返回高频词续接词(输入"美国"→ ["美国", "美国政府", "美国签证"]);zhparser 中文分词 + GIN 数组索引,前端 debounce 250ms 自动补全 +- 🧹 **译文清洗** *(新)*:清洗 LLM 输出里残留的 markdown 加粗标记(`**FBI**` → `FBI`)— pipeline 写库前源头防御 + `app/scripts/clean_translations.py` 批量清洗历史脏数据(1453 条 / 179K 字符实测) 后端用 zhparser 中文分词 + PG 全文搜索 + 候选词固化表,前端 debounce 250ms 自动补全 - 🔄 **热加载**:源/提示词改了不用重启,worker 每天 00:30 重建 job - 🚀 **一键部署**:SSH 推公钥 + 一键 `git pull` 流程 @@ -563,7 +564,7 @@ docker compose exec api alembic upgrade head | 任务 | 输出字段 | LLM 类型 | 用途 | |---|---|---|---| -| **排版** | `articles.body_zh_formatted` | chat | 重写译文为网页排版(分段/加粗/列表) | +| **排版** | `articles.body_zh_formatted` | chat | 重写译文为网页排版(分段/层次/列表) | | **分类** | `articles.category` | chat(返 JSON) | 给文章打 1-3 个分类标签 | | **插图** | `articles.image_ai_url` | image | 文生图,英文 prompt 拼自 `title` | | **点评** | `articles.commentary` | chat | 100-200 字评论,客观有深度 | @@ -599,6 +600,26 @@ docker compose exec api alembic upgrade head 每个任务独立 try/except,失败标 `*_status='failed'`,**不影响**其他任务。 `enrichment_loop` 扫 `*_status` 是 `pending/failed/n/a` 的文章,自动重试 failed。 +### 译文清洗(`text_clean`) + +LLM 翻译时偶尔把 markdown 加粗标记(`**FBI**` / `***FBI***` / `*FBI*`)原样带进译文, +前端展示就成了 `**FBI**局长` 这种脏数据。**两层防护**: + +- **源头防御** — `app/services/translation/text_clean.py` 提供 `clean_markdown_asterisks`, + `pipeline.translate_article` 在写库前自动清洗,新翻译不会再产生 `**`。 +- **批量清洗** — `app/scripts/clean_translations.py` 扫所有含 `*` 的文章, + 清洗 5 个字段(`title_zh` / `body_zh_text` / `body_zh_html` / `body_zh_formatted` / `summary_zh`)。 + 评论字段(`commentary` / `commentary_meituan`)不动 — 那是另两条 LLM 产物链。 + +清洗规则(从长到短、循环到稳定、兜底删零散 `*`): +1. `***text***` → `text` (粗+斜) +2. `**text**` → `text` (粗) +3. `*text*` → `text` (斜) +4. 兜底:残留的 `*` / `**` / `***` 一律删除 + +`body_zh_formatted`(LLM 排版产物)用 BeautifulSoup 只清洗文本节点, +保留 `diary-para` class 和内联 style,不影响前端渲染。 + ### 智能搜索建议(autocomplete) 搜索框输入前缀(如"美"),下拉弹出**高频词续接词**: @@ -772,6 +793,7 @@ python scripts\deploy_pull.py # 我帮你跑,你说"拉一下"即可 | `scripts/deploy_pull.py` | 免密拉取 + 失败回滚 | `python scripts\deploy_pull.py` | | `scripts/server_init.py` | 服务器系统级初始化(推公钥 + 7 项运维) | `REMOTE_PASS=xxx python scripts/server_init.py` | | `scripts/push_ssh_key.py` | 单推 SSH 公钥(SSH key fingerprint 去重) | `REMOTE_PASS=xxx python scripts/push_ssh_key.py` | +| `docker compose exec worker python -m app.scripts.clean_translations` | 批量清洗译文 `**` 残留(支持 `--dry-run` / `--limit` / `--source-slug` / `--field`) | 服务器上 | | `docker compose logs -f worker` | 看 worker 日志 | 服务器上 | | `docker compose exec api alembic upgrade head` | 跑 migration | 服务器上 | @@ -854,6 +876,7 @@ PowerShell 默认 GBK,运行前先 `chcp 65001` 切 UTF-8。 - [x] **Phase 1.5**:LLM 智能增强(排版/分类/插图/点评) ✅ 2026-06-08 - [x] **Phase 1.6**:API Push 短新闻(`POST /api/v1/ingest` + 三层去重 + per-token 限速) ✅ 2026-06-14 - [x] **Phase 1.7**:中文源头 RSS 优化(详情页隐藏译文 + 翻译循环跳过省配额) ✅ 2026-06-14 +- [x] **Phase 1.8**:译文清洗(`text_clean` 源头防御 + `clean_translations.py` 批量脚本;首页/详情页 Agnes 标签 + 美团评论完整显示) ✅ 2026-06-16 - [ ] **Phase 2**:PWA 离线缓存 / 关键词订阅推送(Telegram) - [ ] **Phase 3**:Android 客户端(API Token 已预留) - [ ] **Phase 4**:自动分类/点评/实体识别(目前是 LLM 一次性,无 ML pipeline)