Documentation
¶
Overview ¶
Package readability provides text readability metrics including Flesch-Kincaid Grade Level and Flesch Reading Ease scores.
Package syllable provides accurate syllable counting for English text. Ported from https://github.com/words/syllable (MIT License)
Index ¶
- func AutomatedReadabilityIndex(text string) float64
- func AutomatedReadabilityIndexFromStats(stats Stats) float64
- func AutomatedReadabilityIndexReader(r io.Reader) (float64, error)
- func ColemanLiauIndex(text string) float64
- func ColemanLiauIndexFromStats(stats Stats) float64
- func Count(text string) int
- func CountReader(r io.Reader) (int, error)
- func FleschKincaidGrade(text string) float64
- func FleschKincaidGradeFromStats(stats Stats) float64
- func FleschKincaidGradeReader(r io.Reader) (float64, error)
- func FleschReadingEase(text string) float64
- func FleschReadingEaseFromStats(stats Stats) float64
- func FleschReadingEaseReader(r io.Reader) (float64, error)
- func GunningFogIndex(text string) float64
- func GunningFogIndexFromStats(stats Stats) float64
- func SMOGIndex(text string) float64
- func SMOGIndexFromStats(stats Stats) float64
- type Analyzer
- type Counter
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutomatedReadabilityIndex ¶
AutomatedReadabilityIndex returns the ARI score for a string. Uses character count instead of syllables, making it faster to compute. Output is a US grade level approximation.
func AutomatedReadabilityIndexFromStats ¶
AutomatedReadabilityIndexFromStats calculates ARI from pre-computed stats. Formula: 4.71 × (characters/words) + 0.5 × (words/sentences) − 21.43
func AutomatedReadabilityIndexReader ¶
AutomatedReadabilityIndexReader calculates ARI from an io.Reader.
func ColemanLiauIndex ¶
ColemanLiauIndex returns the Coleman-Liau Index. Uses character count instead of syllables. Output is a US grade level approximation.
func ColemanLiauIndexFromStats ¶
ColemanLiauIndexFromStats calculates Coleman-Liau from pre-computed stats. Formula: 0.0588 × L − 0.296 × S − 15.8 where L = average letters per 100 words, S = average sentences per 100 words
func CountReader ¶
CountReader counts syllables from an io.Reader.
func FleschKincaidGrade ¶
FleschKincaidGrade returns the Flesch-Kincaid Grade Level for a string. The result maps directly to US grade levels:
- 1.0 = 1st grade
- 5.0 = 5th grade
- 12.0 = 12th grade (senior)
- 13+ = college level
func FleschKincaidGradeFromStats ¶
FleschKincaidGradeFromStats calculates grade level from pre-computed stats. Formula: 0.39 × (words/sentences) + 11.8 × (syllables/words) − 15.59
func FleschKincaidGradeReader ¶
FleschKincaidGradeReader calculates grade level from an io.Reader.
func FleschReadingEase ¶
FleschReadingEase returns the Flesch Reading Ease score for a string. Scores range from 0-100 (higher = easier to read):
- 90-100: Very easy (5th grade)
- 80-89: Easy (6th grade)
- 70-79: Fairly easy (7th grade)
- 60-69: Standard (8th-9th grade)
- 50-59: Fairly difficult (10th-12th grade)
- 30-49: Difficult (college)
- 0-29: Very difficult (college graduate)
func FleschReadingEaseFromStats ¶
FleschReadingEaseFromStats calculates reading ease from pre-computed stats. Formula: 206.835 − 1.015 × (words/sentences) − 84.6 × (syllables/words)
func FleschReadingEaseReader ¶
FleschReadingEaseReader calculates reading ease from an io.Reader.
func GunningFogIndex ¶
GunningFogIndex returns the Gunning Fog Index for a string. Output is a US grade level approximation. Note: This is an approximation as it estimates complex words from syllable count.
func GunningFogIndexFromStats ¶
GunningFogIndexFromStats calculates Gunning Fog from pre-computed stats. Formula: 0.4 × [(words/sentences) + 100 × (complex words/words)] Complex words are estimated as words with 3+ syllables.
func SMOGIndex ¶
SMOGIndex returns the SMOG (Simple Measure of Gobbledygook) index. Most accurate for texts with 30+ sentences. Output is a US grade level approximation.
func SMOGIndexFromStats ¶
SMOGIndexFromStats calculates SMOG index from pre-computed stats.
Types ¶
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
Analyzer provides streaming text analysis for readability metrics.
func (*Analyzer) ReadFrom ¶
ReadFrom reads and analyzes text from an io.Reader. Implements io.ReaderFrom interface.
func (*Analyzer) WriteString ¶
WriteString processes a string for analysis.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter provides streaming syllable counting.
func (*Counter) ReadFrom ¶
ReadFrom reads from an io.Reader and counts syllables. Implements io.ReaderFrom interface.
func (*Counter) WriteString ¶
WriteString processes a string for syllable counting.