Documentation
¶
Index ¶
- func CountWords(s string) int
- func CyrillicShare(text string) float64
- func FillLines(text string, hits []Hit)
- func MarkerVerdict(rs *RuleSet, hits []Hit, words int) string
- func StripMarkup(text string) string
- func ToSet(items []string) map[string]bool
- func Words(s string) []string
- type Category
- type CategorySpec
- type GenreSpec
- type Hit
- type Morph
- type Penalty
- type Repeat
- type Report
- type Rhythm
- type Rule
- type RuleFile
- type RuleSet
- type RuleSpec
- type RuleTest
- type Score
- type Structure
- type Thresholds
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountWords ¶
func CyrillicShare ¶
func MarkerVerdict ¶
MarkerVerdict - плотность маркеров, а не вердикт об авторстве: абсолютный счёт на длинном тексте всегда давал "AI". Полосы здесь свои, не измеренные.
func StripMarkup ¶ added in v1.1.0
StripMarkup гасит разметку пробелами: длина и переводы строк сохраняются, поэтому номера строк и позиции находок остаются верными.
Types ¶
type CategorySpec ¶
type GenreSpec ¶
type GenreSpec struct {
MuteBans []string `yaml:"mute_bans"`
MuteCategories []string `yaml:"mute_categories"`
// MuteRules снимает отдельное правило внутри категории: в коде "linked to" -
// это связь в модели данных, а в рекламе - уход от конкретики.
MuteRules []string `yaml:"mute_rules"`
// CVHumanTarget - свой порог рваности ритма для этого регистра. Технический
// текст ровнее разговорного, и один порог на всех наказывал документацию.
CVHumanTarget *float64 `yaml:"cv_human_target,omitempty"`
}
type Hit ¶
type Hit struct {
Category string `json:"category"`
Marker string `json:"marker"`
Fix string `json:"fix,omitempty"`
Lift float64 `json:"lift,omitempty"`
Count int `json:"count"`
Positions []int `json:"-"`
Lines []int `json:"lines"`
}
Hit — попадание одного правила.
func EffectiveHardBans ¶
EffectiveHardBans: частотные баны остаются банами только выше плотности 1/N слов.
func ScanHardBans ¶
func ScanMarkers ¶
type Morph ¶
type Morph struct {
Nominalizations int `json:"nominalizations"`
Per100 float64 `json:"per_100_words"`
VerbForms int `json:"verb_forms"`
}
Morph - номинальность. Суффиксная эвристика вместо pymorphy3: не отличает «решение задачи» от «решение принято», апгрейд - морфоанализатор.
type Repeat ¶ added in v1.1.0
Repeat - трёхсловие, повторённое в тексте. Повтор одной и той же формулировки три раза и больше - дефект письма независимо от того, кто писал.
type Report ¶
type Report struct {
Genre string `json:"genre"`
HardBans []Hit `json:"hard_bans"`
Markers []Hit `json:"markers"`
Rhythm Rhythm `json:"rhythm"`
Morph Morph `json:"morph"`
Structure Structure `json:"structure"`
Score Score `json:"score"`
MutedBans int `json:"muted_bans"`
MutedSoft int `json:"muted_markers"`
NotRussian bool `json:"not_russian"`
}
Report — всё, что посчитано по тексту.
type Rhythm ¶
type Rhythm struct {
Sentences int `json:"sentences"`
Words int `json:"words"`
MeanLen float64 `json:"mean_len"`
CVLen float64 `json:"cv_len"`
MinLen int `json:"min_len"`
MaxLen int `json:"max_len"`
MeanWordLen float64 `json:"mean_word_len"`
LongWords float64 `json:"long_word_share"`
EmDash int `json:"em_dash"`
Ellipsis int `json:"ellipsis"`
Parentheses int `json:"parentheses"`
Questions int `json:"questions"`
}
Rhythm — ритм предложений и типографика.
type RuleFile ¶
type RuleFile struct {
Version int `yaml:"version"`
Thresholds Thresholds `yaml:"thresholds"`
FreqBans map[string]int `yaml:"freq_bans"`
HardBans []RuleSpec `yaml:"hard_bans"`
Categories []CategorySpec `yaml:"categories"`
CopyPasteCategory string `yaml:"copy_paste_category"`
Genres map[string]GenreSpec `yaml:"genres"`
}
type RuleSet ¶
type RuleSet struct {
Thresholds Thresholds
FreqBans map[string]int
HardBans []Rule
Categories []Category
CopyPasteCategory string
Genres []string
// contains filtered or unexported fields
}
func LoadBuiltin ¶
LoadBuiltin: вшитый набор по имени. "ru" - русская проза, "en" - английская, "code" - правила для комментариев и коммитов поверх языкового набора.
func (*RuleSet) CVTarget ¶ added in v1.1.0
CVTarget - порог рваности ритма для жанра, общий если своего нет.
type RuleTest ¶ added in v1.7.0
RuleTest - встроенный тест правила: правило обязано сработать на text при expect: true и промолчать при false. Прогоняется в rules_test.go.
type Score ¶
type Score struct {
Value int `json:"score"`
Band string `json:"band"`
Penalties []Penalty `json:"penalties"`
Notes []string `json:"notes,omitempty"`
}
Score — чистота 0-100: не вероятность ИИ, а агрегат метрик для сравнения «было / стало». Веса перенесены из humanizer_metrics/score.py, кроме пункта 6.
type Structure ¶
type Structure struct {
Paragraphs int `json:"paragraphs"`
ParaMeanSent float64 `json:"para_mean_sent"`
ParaCV float64 `json:"para_cv"`
ListItems int `json:"list_items"`
TitleCaseHeads int `json:"title_case_headings"`
TruncatedEnding bool `json:"truncated_ending"`
RepeatPer1000 float64 `json:"repeat_per_1000"`
Repeats []Repeat `json:"repeats,omitempty"`
}
Structure — метрики уровня документа.
type Thresholds ¶
type Thresholds struct {
CVHumanTarget float64 `yaml:"cv_human_target"`
CVAIThreshold float64 `yaml:"cv_ai_threshold"`
NominalTarget float64 `yaml:"nominal_target"`
ParaCVAI float64 `yaml:"para_cv_ai"`
ParaMinCount int `yaml:"para_min_count"`
ListicleMinItems int `yaml:"listicle_min_items"`
BandClean int `yaml:"band_clean"`
BandEdit int `yaml:"band_edit"`
}