novel-truncator

Truncates novel text to a maximum length at chapter or sentence boundaries.

410|79|Updated Jan 10, 2026
One-click install
npx skills add https://github.com/VanGong1999/screen-creative-skills --skill novel-truncator-vangong1999
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: novel-truncator
Source: https://github.com/VanGong1999/screen-creative-skills/tree/main/category/novel-screening/novel-truncator
Command: npx skills add https://github.com/VanGong1999/screen-creative-skills --skill novel-truncator-vangong1999

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Long novel texts often exceed the input length limits of downstream AI agents or processing pipelines, and naive character-based cutting breaks sentences, chapters, and narrative coherence. This Skill truncates text to a specified maximum length while preserving semantic and structural integrity. ## Core Features & Use Cases - Boundary-aware truncation: Cuts text at chapter headings (第X章, Chapter X, 楔子, etc.), sentence endings (。!?), or paragraph breaks instead of mid-word positions. - Chapter extraction and statistics: Identifies chapter titles, extracts chapter lists, and reports truncation ratios and chapter counts before and after cutting. - Batch and file processing: Truncates multiple novels at once or reads text directly from UTF-8 files with structured status-code responses. - Use Case: Before sending a 200,000-character web novel to an evaluation agent with a 50,000-character limit, truncate it at the nearest chapter boundary so the agent receives complete chapters rather than a broken fragment. ## Quick Start Truncate this novel text to at most 50,000 characters, cutting at the nearest chapter or sentence boundary and reporting the original and truncated lengths.

Frequently Asked Questions about novel-truncator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I truncate a long novel without breaking sentences?▼

Pass the text and a max_length to the truncate_novel function, which searches for sentence-ending punctuation (。!?) near the limit and cuts there instead of mid-word. It falls back to paragraph breaks or a hard cut only if no boundary is found.

How to split Chinese web novels by chapter in Python?▼

Use the extract_chapters method, which matches common Chinese chapter patterns like 第X章, 第X回, 楔子, and 序章 with regular expressions. It returns each chapter's title, start and end positions, and a content preview.

Does the truncator prioritize chapter boundaries over sentence boundaries?▼

Yes, when preserve_chapter is true it first searches for chapter headings within roughly 70-100% of the maximum length and cuts there. If no suitable chapter boundary exists, it falls back to sentence-boundary truncation automatically.

Can I truncate novel text directly from a file?▼

Yes, the truncate_novel_from_file method reads a UTF-8 text file and truncates its contents in one call. It returns distinct error codes for missing files, encoding failures, and other read errors.

What happens if the text is shorter than the maximum length?▼

The function returns the original text unchanged with a truncated flag set to false. The metadata still reports the original and truncated lengths so callers can handle both cases uniformly.

What are the limitations of regex-based chapter detection?▼

Chapter detection depends on predefined heading patterns, so novels with unconventional or missing chapter titles will not match. In those cases the truncator silently falls back to sentence or paragraph boundary cutting.