#!/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} ## 【爽点一:谈判桌上的信息碾压】 陈末走进周世昌的办公室,目光扫过室内陈设。简朴,但每件东西都透着实用主义的气息。周世昌坐在宽大的办公桌后,手指轻轻敲击桌面,眼神锐利如鹰。 “坐。”周世昌指了指对面的椅子,“你说有重要消息,我时间不多。” 陈末坐下,从口袋里掏出那张五万的欠条,放在桌上。“周老板,先看看这个。” 周世昌瞥了一眼,嘴角微扬:“鑫隆财富的欠条?五万?这东西现在跟废纸差不多。” “现在确实是废纸。”陈末平静地说,“但六天后,它会值点钱。” 周世昌的手指停住:“什么意思?” “稳盈宝,六月十八号。”陈末只说了两个词。 办公室里的空气瞬间凝固。周世昌身体前倾,眼神变得危险:“你从哪里知道的消息?” “这不重要。”陈末迎上他的目光,“重要的是,这个消息值多少钱?” ## 【爽点二:心理博弈,掌控节奏】 周世昌盯着陈末看了足足十秒,忽然笑了:“年轻人,敢来我这里卖消息的,你不是第一个。但敢这么直接的,你是头一个。” “因为时间不多了。”陈末看了眼手表,“还有六天。六天后,这个消息一文不值。” “我怎么知道你不是在胡说八道?”周世昌点燃一支烟,烟雾缓缓升起。 陈末从口袋里掏出一张纸条,上面写着一个名字和电话号码。“胡老板,做建材生意的。他在稳盈宝投了八千万,现在正在疯狂找人接盘。” 周世昌接过纸条,眼神闪烁。他拿起手机,拨了个号码,低声说了几句。挂断后,他重新看向陈末。 “胡老板确实在找接盘的,开价五折。”周世昌弹了弹烟灰,“但这只能证明稳盈宝有问题,不能证明它六天后就爆。” 陈末从口袋里又掏出一张纸,这次是打印的聊天记录截图。“这是胡老板手下的财务主管,昨天在内部群里发的消息:'大额赎回全部延迟到十八号以后处理。'” 周世昌的脸色终于变了。他掐灭烟头,站起身走到窗前,沉默了几分钟。 “你要多少?”他背对着陈末问道。 ## 【爽点三:达成交易,获取资源】 “二十万现金。”