novel-doomsday-resurgence/tools/fix_critical_titles.py
唐天洛 2003fa15ef 章节标题质量改进系统完成
 修复关键标题问题:
1. 筹码_手动修复 → 致命筹码
2. 修复 → 心灵修复
3. 对峙(2) → 生死对峙

 创建完整质量检查与修复工具集:
1. chapter_title_qc.py - 标题质量分析系统
2. apply_title_fixes.py - 自动修复工具
3. clean_ai_markers.py - AI标记清理工具
4. final_format_fix.py - 最终格式修复工具
5. improve_all_titles.py - 全面标题改进工具

 所有29个章节标题质量均已优化,评分A级以上
 移除爽点分析内容,确保正文纯净
 提升标题吸引力和阅读体验
2026-03-30 14:53:52 +08:00

93 lines
2.8 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
"""
修复最关键的标题问题
"""
import os
import re
CHAPTERS_DIR = "/root/.openclaw/workspace/projects/末日重生_囤货/chapters"
# 最需要修复的标题评分C级或以下
CRITICAL_FIXES = {
'筹码_手动修复': '致命筹码',
'修复': '心灵修复',
'对峙2': '生死对峙',
}
def fix_critical_titles():
"""修复最关键的标题"""
print("🔧 修复最关键标题问题")
print("=" * 50)
# 获取所有章节文件
chapter_files = [f for f in os.listdir(CHAPTERS_DIR) if f.endswith('.md')]
# 查找需要修复的文件
files_to_fix = []
for filename in chapter_files:
# 提取原标题
match = re.search(r'ch\d+-第\d+章\s+(.+)\.md', filename)
if not match:
continue
old_title = match.group(1)
# 检查是否需要修复
if old_title in CRITICAL_FIXES:
new_title = CRITICAL_FIXES[old_title]
files_to_fix.append((filename, old_title, new_title))
if not files_to_fix:
print("✅ 没有需要修复的关键标题")
return
print(f"发现 {len(files_to_fix)} 个需要修复的关键标题:")
for filename, old_title, new_title in files_to_fix:
print(f" {old_title}{new_title}")
print("\n🔄 开始修复...")
# 执行修复
fixed_count = 0
for filename, old_title, new_title in files_to_fix:
filepath = os.path.join(CHAPTERS_DIR, filename)
# 读取文件内容
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
# 提取章节号
match = re.search(r'ch(\d+)-第\d+章\s+(.+)\.md', filename)
chapter_num = match.group(1)
# 构建新文件名
new_filename = f"ch{chapter_num}-第{chapter_num}{new_title}.md"
new_filepath = os.path.join(CHAPTERS_DIR, new_filename)
# 更新标题
old_header = f"# 第{chapter_num}{old_title}"
new_header = f"# 第{chapter_num}{new_title}"
if old_header in content:
content = content.replace(old_header, new_header, 1)
# 写入文件
with open(new_filepath, 'w', encoding='utf-8') as f:
f.write(content)
# 如果文件名改变,删除旧文件
if new_filename != filename:
os.remove(filepath)
print(f"✅ 修复: {filename}{new_filename}")
else:
print(f"✅ 更新标题: {old_title}{new_title}")
fixed_count += 1
print(f"\n📊 修复完成! 共修复 {fixed_count} 个关键标题")
if __name__ == '__main__':
fix_critical_titles()