INNER CODE UNIT · Python
check_chapter
voocel/ainovel-cli · scripts/check_chapter_wordcount.py:46
def check_chapter(file_path: str, min_words: int = 3000) -> dict:
"""检查单个章节的字数"""
path = Path(file_path)
if not path.exists():
return {
'file': str(path),
'exists': False,
'word_count': 0,
'status': 'error',
'message': f'文件不存在: {file_path}',
}
main_content = extract_content_from_chapter(path)
word_count = count_chinese_words(main_content)
status = 'pass' if word_count >= min_words else 'fail'
message = f'字数: {word_count}'
if word_count >= min_words:
message += ' (✓ 达标)'