stylestat

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package stylestat 对已写正文做全书级风格统计,产出纯事实。

动机:弧内评审窗口(~10 章)对全书级模式固化天然失明——句式 tic 章均几十次、 章末形态同构、跨章复读,单章看每处都"正常",只有全书统计能暴露。统计归代码 (确定性、零幻觉),裁定归 LLM(editor 按数字判维度分,writer 据此自避免)。 Compute 供离线评测一次性全量计算;运行时使用 Tracker 按章节增量维护。

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 章末行形态分布。短结尾本身合法,全书同构才是问题。

type Input

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

Input 统计输入。Chapters 按章号升序;Stopwords 为角色名等专有名词, 动态短语挖掘时跳过(出场人名天然高频,不是文风问题)。

type PatternStat

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

PatternStat 固定句式模式类的全书计数(通用 AI 文风 tic)。

type PhraseStat

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

PhraseStat 最近 phraseWindow 章内挖掘出的高频短语。

type SentenceStat

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

SentenceStat 跨章逐字重复的长句(复读交代的直接证据)。

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 全书风格统计结果。所有字段都是事实计数,不含任何裁定或指令。

func Compute

func Compute(in Input) *Stats

Compute 计算全书风格统计;章数不足时返回 nil。

type TitleStat

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

TitleStat 章节标题「第N章」前缀混用计数(混用=机制痕迹暴露在产物里)。

type Tracker added in v0.7.5

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

Tracker 按章节维护全书风格统计。首次载入每章一次;新增或重写时只分析变化章节。 Snapshot 会缓存派生结果,同一书状态下 Writer/Editor 的重复读取不再重算。

func NewTracker added in v0.7.5

func NewTracker() *Tracker

func (*Tracker) Remove added in v0.7.5

func (t *Tracker) Remove(chapter int)

Remove 删除一章;不存在时无操作。

func (*Tracker) Snapshot added in v0.7.5

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

Snapshot 返回与 Compute 等价的当前统计快照。

func (*Tracker) Upsert added in v0.7.5

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

Upsert 新增或替换一章。正文未变化时不推进版本。

Jump to

Keyboard shortcuts

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