$ show dama-cyber/Casting-Workflow
This repository implements a CLI pipeline for generating Chinese web-novel ('Fanqie'-style) short stories by distilling statistical fingerprints from a user-supplied corpus of genre novels. run_pipeline.py scans a corpus directory, filters out files with under 500 Chinese characters as damaged, randomly samples 5 healthy texts, extracts per-text fingerprints via tools/fusion.py (sentence/punctuation densities, high-frequency names, opening lines), and assembles an LLM prompt built around the 'type common denominator' principle β elements shared by β₯3 of the 5 sources are kept, while author-specific fingerprints are discarded β so the model's output is intended to evade 16-character string-matching plagiarism scans against the source corpus. It also implements a 12-stage 'chained creation' mode (θζ΄ through ζ©ε) that loads prompt templates from a prompt/ directory and optionally carries prior LLM outputs forward with -P. The architecture is a small modular monolith: run_pipeline.py orchestrates; tools/ holds four standalone utilities (fingerprint distillation, jieba-aware comma repair, punctuation-density injection, originality audit); and check_story.py validates output against 9 'viral hit' rules β including a genuinely sophisticated layered heuristic for extracting Chinese character names from text without any ML model. The sole hard dependency is jieba, unpinned. There are no tests and no CI. Critical caveat: this snapshot is incomplete. The corpus/ directory (9 genre folders, referenced throughout README.md and SKILL.md) and the entire prompt/ template library (the 9 prompt_*.md files mapped in prompt/MAPPING.md and required by run_pipeline's STAGE_PROMPT_MAP) are absent from the committed tree. As committed, run_pipeline.py cannot execute end-to-end: default mode errors with 'corpus δΈΊη©Ί', and --stage mode fails to load prompt templates. Only the individual tools (fusion.py with explicit file arguments, clean_commas.py, inject_punctuation.py, audit.py, check_story.py) can run against user-supplied text. The README also conflicts with the code on target story length (README/SKILL say ~1000ε; tools/fusion.py's generated prompt instructs ~10000ε). Domain note: the project's explicit design goal is to make generated text untraceable by the ζ±ι (Zhuque) plagiarism scanner ('ζ±ιζ£ζ΅δΈε°', '0εΉι '), positioning it as an anti-plagiarism-detection content tool β a grey-area use case adopting engineers should evaluate for their own compliance context. Within its niche the engineering is competent: layered name-extraction heuristics, tokenization-aware punctuation repair, robust encoding fallbacks, and clean separation between orchestration and utilities.
The LLM identified 3 files worth highlighting for reuse:
A layered heuristic for extracting Chinese character names from free text without a CRF/ML model. It classifies surnames into compound/strong/medium/weak tiers with different regex contexts and word-boundary requirements; applies linguistic rules (digits, function words, and redundant characters cannot be a name's second character); validates weak-surname candidates against jieba token frequencies (frequency > 200 β common word, not a name); performs compound-word containment checks to reject 'εζΉζ΄ηΎ'β'ζΉζ΄ηΎ' style false positives; and deduplicates prefix variants (θζ vs θζζ) via scoring. Self-contained (only re + jieba), it could be extracted as a standalone `extract_chinese_names(text) -> set[str]` utility for any Chinese text-mining task. This is non-obvious, carefully tuned engineering β far beyond naive surname regexes.
Repairs wrongly inserted full-width commas by checking whether the characters on each side of a comma form a single two-character token under jieba segmentation; if they do, the comma has split a valid word and is deleted. This tokenization-aware approach replaces brittle hand-written regex lists and generalizes to any Chinese text-cleanup pipeline. The algorithm is small, dependency-light (only jieba), idempotent in intent, and trivially extractable into a new project.
The extract_fingerprint function produces a compact statistical-and-structural profile of a Chinese text: Chinese character count, sentence count, exclamation/comma densities, quote usage, the first 30 clean non-boilerplate lines, and top likely character names (jieba word frequency minus a curated stoplist). This is a clean, self-contained text-profiling primitive that can be reused for style clustering, genre detection, corpus deduplication, or authorship comparison β independent of the domain-specific '5-source common-denominator intersection' methodology that consumes it in this repo.