Files
yu-zhi-ran/automation/generate_optimized_md.py
T
lt d63074be71 chore: 更新项目路径到新工作区
- 所有自动化脚本、测试文件路径从旧工作区迁移到 /root/openclaw-workspace/projects/yu-zhi-ran/
- 保持项目独立于 OpenClaw 工作区管理
- 后端 run.sh 路径更新
2026-04-27 18:49:32 +08:00

51 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
对 article.md 进行内容优化:
- 去除具体 App 品牌名(花帮主、园艺助手)
- 隐去设备具体品牌(小米米家)
- 保留功能描述和用户价值
- 保持中立、实用、无广告感
"""
import os
import re
BASE_DIR = "/root/openclaw-workspace/projects/yu-zhi-ran/content/published/2026-04-14-上海阳台种菜一年"
MD_FILE = os.path.join(BASE_DIR, "final-article.md")
OUT_MD = os.path.join(BASE_DIR, "final-article-optimized.md")
with open(MD_FILE, "r", encoding="utf-8") as f:
content = f.read()
# 1. 替换具体 App 名称 -> 通用描述
content = re.sub(r'花帮主', '一些第三方种植App', content)
content = re.sub(r'园艺助手', '另一些生活助手类App', content)
content = re.sub(r'(\*\*)花帮主(\*\*)AI识别病虫害,准确率85%', '**一些第三方种植App**,可以通过 AI 识别病虫害,准确率在 80% 以上', content)
# 2. 替换设备品牌 -> 通用描述
content = re.sub(r'小米米家灌溉套装', '智能灌溉套装', content)
content = re.sub(r'LED补光灯', 'LED 植物补光灯', content)
# 3. 移除可能带有广告嫌疑的表述(如“效果最好”、“推荐”等),改为中性描述
content = re.sub(r'强烈推荐(易种)', '适合新手(易种)', content)
content = re.sub(r'强烈推荐', '推荐', content)
# 4. 图片描述调整(不影响图片本身,只调整 alt 文本和图片说明)
# 图片文件保留不变,只调整 Markdown 中的说明文字
content = re.sub(r'!\[App截图\]', '[App功能截图]', content)
content = re.sub(r'App截图', 'App功能界面示意', content)
# 5. 增加免责声明(在文末)
if "声明:" not in content:
content = content.rstrip() + "\n\n---\n\n> **声明**:本文提及的工具和设备仅为个人使用经验分享,不构成商业推荐。读者可根据自身需求选择类似产品。\n"
with open(OUT_MD, "w", encoding="utf-8") as f:
f.write(content)
print(f"✅ 优化完成: {OUT_MD}")
print("🔧 优化项:")
print(" - 去除具体 App 品牌名")
print(" - 隐去设备品牌")
print(" - 增加中立表述")
print(" - 添加免责声明")