✅ 修复关键标题问题: 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级以上 ✅ 移除爽点分析内容,确保正文纯净 ✅ 提升标题吸引力和阅读体验
108 lines
3.5 KiB
Python
108 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
精确移除爽点分析内容,保留正常的心理描写
|
||
"""
|
||
|
||
import os
|
||
import re
|
||
|
||
CHAPTERS_DIR = "/root/.openclaw/workspace/projects/末日重生_囤货/chapters"
|
||
|
||
def precise_remove_shuangdian(content):
|
||
"""
|
||
精确移除爽点分析,保留正常的心理描写
|
||
"""
|
||
lines = content.split('\n')
|
||
result_lines = []
|
||
|
||
i = 0
|
||
while i < len(lines):
|
||
line = lines[i]
|
||
|
||
# 1. 移除特定的爽点分析句子(精确匹配)
|
||
if '展现重生者的先知优势' in line or '利用未来信息获取利益' in line:
|
||
# 跳过这一行
|
||
i += 1
|
||
continue
|
||
|
||
# 2. 移除"谈判桌上,陈末掌握着对手的所有底牌"这一段
|
||
if '谈判桌上,陈末掌握着对手的所有底牌' in line:
|
||
# 跳过这一段(通常3行)
|
||
i += 3
|
||
continue
|
||
|
||
# 3. 检查是否是爽点标题行
|
||
if re.search(r'^#\s*【爽点[一二三四五六七八九十]?[::]', line):
|
||
# 跳过爽点标题行
|
||
i += 1
|
||
# 检查下一行是否是爽点内容
|
||
while i < len(lines) and lines[i].strip() and not lines[i].startswith('#') and not re.search(r'【爽点[一二三四五六七八九十]?[::]', lines[i]):
|
||
i += 1
|
||
continue
|
||
|
||
# 4. 保留正常的心理描写(如「一周后爆雷,这个消息值多少钱?」)
|
||
# 这些是正常的心理活动,不应该被移除
|
||
|
||
result_lines.append(line)
|
||
i += 1
|
||
|
||
# 重新组合内容
|
||
result = '\n'.join(result_lines)
|
||
|
||
# 5. 清理多余的空白行
|
||
result = re.sub(r'\n{3,}', '\n\n', result)
|
||
|
||
# 6. 确保章节以正确的标题结束
|
||
# 移除末尾可能遗留的爽点内容
|
||
lines = result.split('\n')
|
||
cleaned_lines = []
|
||
for line in lines:
|
||
if '【爽点:' in line and '重生者的先知优势' in line:
|
||
continue
|
||
cleaned_lines.append(line)
|
||
|
||
result = '\n'.join(cleaned_lines)
|
||
|
||
return result.strip()
|
||
|
||
def main():
|
||
print("精确移除爽点分析内容...")
|
||
|
||
chapter_files = [f for f in os.listdir(CHAPTERS_DIR) if f.endswith('.md')]
|
||
|
||
# 先检查哪些文件需要修复
|
||
for filename in sorted(chapter_files):
|
||
filepath = os.path.join(CHAPTERS_DIR, filename)
|
||
|
||
with open(filepath, 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
|
||
# 检查是否有需要修复的内容
|
||
needs_fix = (
|
||
'展现重生者的先知优势' in content or
|
||
'谈判桌上,陈末掌握着对手的所有底牌' in content or
|
||
re.search(r'^#\s*【爽点[一二三四五六七八九十]?[::]', content, re.MULTILINE)
|
||
)
|
||
|
||
if needs_fix:
|
||
print(f"修复: {filename}")
|
||
|
||
# 创建备份
|
||
backup_path = filepath + '.precise.bak'
|
||
with open(backup_path, 'w', encoding='utf-8') as f:
|
||
f.write(content)
|
||
|
||
# 应用修复
|
||
fixed_content = precise_remove_shuangdian(content)
|
||
|
||
with open(filepath, 'w', encoding='utf-8') as f:
|
||
f.write(fixed_content)
|
||
|
||
print(f" ✓ 已精确修复")
|
||
else:
|
||
print(f"检查: {filename} ✓ 无需修复")
|
||
|
||
print("\n精确修复完成!")
|
||
|
||
if __name__ == '__main__':
|
||
main() |