Skip to content
This repository has been archived by the owner on May 14, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of ssh://github.com/jdkato/prose
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Aug 14, 2019
2 parents d811427 + 8834f53 commit 778cdf2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions summarize/readability.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ func (d *Document) GunningFog() float64 {
return 0.4 * (x + 100.0*y)
}

// LIX computes readability measure
// (https://en.wikipedia.org/wiki/Lix_(readability_test)) .
func (d *Document) LIX() float64 {
return (d.NumWords / d.NumSentences) + ((d.NumLongWords * 100) / d.NumWords)
}

// SMOG computes the SMOG grade (https://en.wikipedia.org/wiki/SMOG).
func (d *Document) SMOG() float64 {
return 1.0430*math.Sqrt(d.NumPolysylWords*30.0/d.NumSentences) + 3.1291
Expand Down
4 changes: 4 additions & 0 deletions summarize/summarize.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Document struct {
NumSentences float64 // Number of sentences
NumSyllables float64 // Number of syllables
NumWords float64 // Number of words
NumLongWords float64 // Number of long words
Sentences []Sentence // the Document's sentences
WordFrequency map[string]int // [word]frequency

Expand Down Expand Up @@ -113,6 +114,9 @@ func (d *Document) Initialize() {
} else {
d.WordFrequency[word] = 1
}
if len(word) > 6 {
d.NumLongWords++
}
syllables := Syllables(word)
words = append(words, Word{Text: word, Syllables: syllables})
d.NumSyllables += float64(syllables)
Expand Down

0 comments on commit 778cdf2

Please sign in to comment.