介绍
# Humanize CLI
用于检测并自动修复 AI 写作模式的命令行工具。
## 脚本
### analyze.py — 检测 AI 模式
扫描文本并报告 AI 词汇、虚饰语、聊天机器人痕迹以及可自动替换的短语。
```bash # Analyze a file python scripts/analyze.py input.txt
# Analyze from stdin echo "This serves as a testament to our commitment" | python scripts/analyze.py
# JSON output for programmatic use python scripts/analyze.py input.txt --json ```
**输出示例:** ``` ================================================== AI PATTERN ANALYSIS - 5 issues found ==================================================
AI VOCABULARY: • testament: 1x • crucial: 2x
AUTO-REPLACEABLE: • "serves as" → "is": 1x • "in order to" → "to": 1x ```
---
### humanize.py — 自动替换模式
对常见的 AI 写作惯用语执行自动替换。
```bash # Humanize and print to stdout python scripts/humanize.py input.txt
# Write to output file python scripts/humanize.py input.txt -o output.txt
# Include em dash replacement python scripts/humanize.py input.txt --fix-dashes
# Quiet mode (no change log) python scripts/humanize.py input.txt -q ```
**自动修复的内容:** - 填充短语:"in order to" → "to","due to the fact that" → "because" - 系动词回避:"serves as" → "is","boasts" → "has" - 句首词:移除 "Additionally,"、"Furthermore,"、"Moreover," - 弯引号 → 直引号 - 聊天机器人痕迹:移除 "I hope this helps"、"Let me know if" 等。
---
## 工作流
1. **先分析** 以查看需要修复的内容: ```bash python scripts/analyze.py document.txt ```
2. **自动修复** 安全的替换项: ```bash python scripts/humanize.py document.txt -o document_clean.txt ```
3. **人工审核** analyze 标记出的 AI 词汇和虚饰语(这些需要人工判断)
4. **重新分析** 以确认改进效果: ```bash python scripts/analyze.py document_clean.txt ```
---
## 自定义模式
编辑 `scripts/patterns.json` 来添加/删除: - `ai_words` — 会标记但不自动替换的词汇 - `puffery` — 需要标记的宣传性语言 - `replacements` — 短语 → 替换项的映射(空字符串表示删除) - `chatbot_artifacts` — 需要自动移除的短语 - `hedging_phrases` — 需要标记的过度模糊表达
---
## 批量处理
处理多个文件:
```bash # Analyze all markdown files for f in *.md; do echo "=== $f ===" python scripts/analyze.py "$f" done
# Humanize all txt files in place for f in *.txt; do python scripts/humanize.py "$f" -o "$f.tmp" && mv "$f.tmp" "$f" done ```
---