101 lines
3.0 KiB
Python
101 lines
3.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
import re, os, glob
|
|
|
|
CHAPTER_DIR = "."
|
|
files = glob.glob(os.path.join(CHAPTER_DIR, "第*.md"))
|
|
|
|
def check():
|
|
ai_indicators = {
|
|
"握紧": 0, "攥紧": 0, "燃点": 0,
|
|
"深吸一口气": 0, "独立行": 0,
|
|
"全书完标注": 0, "章末标注": 0
|
|
}
|
|
sensitive = {"公司": 0, "集团": 0, "企业": 0, "裁员": 0, "辞退": 0}
|
|
passive = {"被替代": 0, "被代替": 0, "被淘汰": 0, "被替换": 0}
|
|
chapter_counts = {}
|
|
|
|
total_hz = 0
|
|
total_ch = 0
|
|
|
|
for f in sorted(files):
|
|
bn = os.path.basename(f)
|
|
if "番茄版" in bn or bn in ("batch_fix.py", "quality_check.py"):
|
|
continue
|
|
text = open(f, encoding='utf-8').read()
|
|
hz = len(re.findall(r'[\u4e00-\u9fff]', text))
|
|
chapter_counts[bn] = hz
|
|
total_hz += hz
|
|
total_ch += 1
|
|
|
|
for line in text.split('\n'):
|
|
s = line.strip()
|
|
if s in ('——', '————', '——————', '——————'):
|
|
ai_indicators["独立行"] += 1
|
|
|
|
if "(全书完)" in text or "(全书完)" in text:
|
|
ai_indicators["全书完标注"] += 1
|
|
|
|
ms = re.findall(r'\(第.*章.*完\)', text)
|
|
if ms:
|
|
ai_indicators["章末标注"] += len(ms)
|
|
|
|
for w in ("握紧", "攥紧", "燃点", "深吸一口气"):
|
|
cnt = text.count(w)
|
|
if cnt > 0:
|
|
ai_indicators[w] += cnt
|
|
|
|
for w in sensitive:
|
|
sensitive[w] += text.count(w)
|
|
for w in passive:
|
|
passive[w] += text.count(w)
|
|
|
|
|
|
# print report
|
|
print("=" * 60)
|
|
print("【最终质量检查报告】")
|
|
print("=" * 60)
|
|
print(f"\n检查章节数: {total_ch}")
|
|
print(f"全本总汉字: ~{total_hz}")
|
|
print(f"章均汉字: ~{total_hz // total_ch}")
|
|
|
|
below = {k: v for k, v in chapter_counts.items() if v < 2500}
|
|
if below:
|
|
print(f"\n⚠️ 字数不足 (<2500): {len(below)}章")
|
|
for k, v in sorted(below.items()):
|
|
print(f" {k}: {v}字")
|
|
else:
|
|
print(f"\n✅ 汉字字数: 全部达标")
|
|
|
|
print(f"\n--- AI味检查 ---")
|
|
all_clean = True
|
|
for k, v in ai_indicators.items():
|
|
status = "✅" if v == 0 else "⚠️"
|
|
print(f" {status} {k}: {v}次")
|
|
if v > 0:
|
|
all_clean = False
|
|
|
|
print(f"\n--- 敏感词 ---")
|
|
for k, v in sensitive.items():
|
|
status = "✅" if v == 0 else "❌"
|
|
print(f" {status} {k}: {v}次")
|
|
if v > 0:
|
|
all_clean = False
|
|
|
|
print(f"\n--- 被动叙事 ---")
|
|
for k, v in passive.items():
|
|
status = "✅" if v == 0 else "⚠️"
|
|
print(f" {status} {k}: {v}次")
|
|
if v > 0:
|
|
all_clean = False
|
|
|
|
print()
|
|
print("=" * 60)
|
|
if all_clean:
|
|
print("【总体评价: S级】全部达标")
|
|
else:
|
|
print("【总体评价: 需要修复】")
|
|
print("=" * 60)
|
|
|
|
if __name__ == "__main__":
|
|
check()
|