stylestat

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package stylestat computes book-wide style statistics over already-written prose and produces pure facts.

Motivation: an in-arc review window (~10 chapters) is blind by construction to book-wide pattern hardening -- a tic seen dozens of times per chapter, isomorphic chapter endings and cross-chapter repetition all look "normal" chapter by chapter, and only book-wide statistics expose them. Counting belongs to the code (deterministic, zero hallucination), judgement to the LLM (editor scores dimensions from the numbers, writer avoids them). Compute is the offline one-shot path, Tracker the runtime one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EndingStat

type EndingStat struct {
	ShortRatio  float64 `json:"short_ratio"`
	MedianRunes int     `json:"median_runes"`
}

EndingStat is the distribution of chapter-final line shapes. A short ending is legitimate on its own; book-wide isomorphism is the problem.

type Input

type Input struct {
	Chapters  []string
	Titles    []string
	Stopwords []string
}

Input is the statistics input. Chapters is ordered by ascending chapter number; Stopwords holds proper nouns such as character names, which are skipped during dynamic phrase mining (a recurring character name is naturally frequent, not a style problem).

type PatternStat

type PatternStat struct {
	Name       string  `json:"name"`
	Total      int     `json:"total"`
	PerChapter float64 `json:"per_chapter"`
}

PatternStat is the book-wide count of fixed sentence-pattern classes (generic AI prose tics).

type PhraseStat

type PhraseStat struct {
	Text  string `json:"text"`
	Count int    `json:"count"`
}

PhraseStat holds the frequent phrases mined from the last phraseWindow chapters.

type SentenceStat

type SentenceStat struct {
	Text     string `json:"text"`
	Chapters int    `json:"chapters"`
	Count    int    `json:"count"`
}

SentenceStat holds long sentences repeated verbatim across chapters (direct evidence of padding recaps).

type Stats

type Stats struct {
	Chapters          int            `json:"chapters"`
	Patterns          []PatternStat  `json:"patterns,omitempty"`
	TopPhrases        []PhraseStat   `json:"top_phrases,omitempty"`
	RepeatedSentences []SentenceStat `json:"repeated_sentences,omitempty"`
	Ending            EndingStat     `json:"ending"`
	OpeningTimeRate   float64        `json:"opening_time_rate"`
	TitleFormats      *TitleStat     `json:"title_formats,omitempty"`
}

Stats is the book-wide style statistics result. Every field is a factual count, with no verdict and no instruction.

func Compute

func Compute(in Input) *Stats

Compute calculates the book-wide style statistics; it returns nil when there are too few chapters.

type TitleStat

type TitleStat struct {
	WithPrefix    int `json:"with_prefix"`
	WithoutPrefix int `json:"without_prefix"`
}

TitleStat counts mixed use of the "Chapter N" title prefix (mixing = the machinery showing through in the artifact).

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker maintains the book-wide style statistics per chapter. On first load every chapter is analysed once; on append or rewrite only the changed chapters are. Snapshot caches the derived results, so repeated Writer/Editor reads in the same book state are not recomputed.

func NewTracker

func NewTracker() *Tracker

func (*Tracker) Remove

func (t *Tracker) Remove(chapter int)

Remove deletes one chapter; a missing chapter is a no-op.

func (*Tracker) Snapshot

func (t *Tracker) Snapshot(titles, stopwords []string) *Stats

Snapshot returns a snapshot of the current statistics, equivalent to Compute.

func (*Tracker) Upsert

func (t *Tracker) Upsert(chapter int, text string)

Upsert adds or replaces one chapter. The version is not bumped when the body text is unchanged.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL