novel-doomsday-resurgence/deep_fix_chapters.py

127 lines
5.5 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
"""
深度修复章节脚本
完全重写问题严重的章节
"""
import os
import re
import sys
from pathlib import Path
class DeepChapterFixer:
def __init__(self):
self.templates = {
"交易章节": self.template_transaction,
"行动章节": self.template_action,
"冲突章节": self.template_conflict,
"规划章节": self.template_planning
}
def deep_fix_chapter(self, filepath, chapter_num, chapter_title):
"""深度修复单个章节"""
print(f"深度修复: 第{chapter_num}章《{chapter_title}")
# 读取原始内容
with open(filepath, 'r', encoding='utf-8') as f:
original_content = f.read()
# 分析章节类型
chapter_type = self.analyze_chapter_type(original_content, chapter_title)
# 使用对应模板重写
if chapter_type in self.templates:
new_content = self.templates[chapter_type](chapter_num, chapter_title, original_content)
else:
new_content = self.template_general(chapter_num, chapter_title, original_content)
# 保存修复后的文件
fixed_path = filepath.replace('.md', '_deep_fixed.md')
with open(fixed_path, 'w', encoding='utf-8') as f:
f.write(new_content)
# 质量检查
quality_score = self.quality_check(new_content)
return {
"chapter": chapter_num,
"title": chapter_title,
"type": chapter_type,
"original_length": len(original_content),
"new_length": len(new_content),
"length_change": len(new_content) - len(original_content),
"quality_score": quality_score,
"fixed_file": fixed_path
}
def analyze_chapter_type(self, content, title):
"""分析章节类型"""
content_lower = content.lower()
title_lower = title.lower()
if any(word in title_lower for word in ["交易", "谈判", "筹码", "质询", "协议"]):
return "交易章节"
elif any(word in title_lower for word in ["行动", "囤货", "采购", "运输", "建设"]):
return "行动章节"
elif any(word in title_lower for word in ["冲突", "对峙", "威胁", "危险", "跟踪"]):
return "冲突章节"
elif any(word in title_lower for word in ["规划", "计算", "准备", "倒计时", "时间"]):
return "规划章节"
else:
# 根据内容判断
if "谈判" in content_lower or "交易" in content_lower or "协议" in content_lower:
return "交易章节"
elif "行动" in content_lower or "开始" in content_lower or "准备" in content_lower:
return "行动章节"
elif "危险" in content_lower or "威胁" in content_lower or "冲突" in content_lower:
return "冲突章节"
else:
return "规划章节"
def template_transaction(self, chapter_num, chapter_title, original_content):
"""交易章节模板"""
template = f"""# 第{chapter_num}{chapter_title}
## 【爽点一:谈判桌上的信息碾压】
陈末走进周世昌的办公室目光扫过室内陈设简朴但每件东西都透着实用主义的气息周世昌坐在宽大的办公桌后手指轻轻敲击桌面眼神锐利如鹰
周世昌指了指对面的椅子你说有重要消息我时间不多
陈末坐下从口袋里掏出那张五万的欠条放在桌上周老板先看看这个
周世昌瞥了一眼嘴角微扬鑫隆财富的欠条五万这东西现在跟废纸差不多
现在确实是废纸陈末平静地说但六天后它会值点钱
周世昌的手指停住什么意思
稳盈宝六月十八号陈末只说了两个词
办公室里的空气瞬间凝固周世昌身体前倾眼神变得危险你从哪里知道的消息
这不重要陈末迎上他的目光重要的是这个消息值多少钱
## 【爽点二:心理博弈,掌控节奏】
周世昌盯着陈末看了足足十秒忽然笑了年轻人敢来我这里卖消息的你不是第一个但敢这么直接的你是头一个
因为时间不多了陈末看了眼手表还有六天六天后这个消息一文不值
我怎么知道你不是在胡说八道周世昌点燃一支烟烟雾缓缓升起
陈末从口袋里掏出一张纸条上面写着一个名字和电话号码胡老板做建材生意的他在稳盈宝投了八千万现在正在疯狂找人接盘
周世昌接过纸条眼神闪烁他拿起手机拨了个号码低声说了几句挂断后他重新看向陈末
胡老板确实在找接盘的开价五折周世昌弹了弹烟灰但这只能证明稳盈宝有问题不能证明它六天后就爆
陈末从口袋里又掏出一张纸这次是打印的聊天记录截图这是胡老板手下的财务主管昨天在内部群里发的消息'大额赎回全部延迟到十八号以后处理。'
周世昌的脸色终于变了他掐灭烟头站起身走到窗前沉默了几分钟
你要多少他背对着陈末问道
## 【爽点三:达成交易,获取资源】
二十万现金