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

Commit

Permalink
Add LIX tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Aug 14, 2019
1 parent 778cdf2 commit 1210784
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions summarize/readability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestReadability(t *testing.T) {
assert.True(t, check(test.StdDevGrade, a.StdDevGradeLevel))
assert.True(t, check(test.DaleChall, a.DaleChall))
assert.True(t, check(test.ReadingEase, a.ReadingEase))
assert.True(t, check(test.LIX, a.LIX))
}
}

Expand Down
4 changes: 3 additions & 1 deletion summarize/summarize.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type Assessment struct {
FleschKincaid float64
GunningFog float64
SMOG float64
LIX float64

// mean & standard deviation of the above estimated grade levels
MeanGradeLevel float64
Expand Down Expand Up @@ -143,7 +144,8 @@ func (d *Document) Assess() *Assessment {
a := Assessment{
FleschKincaid: d.FleschKincaid(), ReadingEase: d.FleschReadingEase(),
GunningFog: d.GunningFog(), SMOG: d.SMOG(), DaleChall: d.DaleChall(),
AutomatedReadability: d.AutomatedReadability(), ColemanLiau: d.ColemanLiau()}
AutomatedReadability: d.AutomatedReadability(), ColemanLiau: d.ColemanLiau(),
LIX: d.LIX()}

gradeScores := []float64{
a.FleschKincaid, a.AutomatedReadability, a.GunningFog, a.SMOG,
Expand Down
1 change: 1 addition & 0 deletions summarize/summarize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type testCase struct {
FleschKincaid float64
GunningFog float64
SMOG float64
LIX float64

MeanGrade float64
StdDevGrade float64
Expand Down
9 changes: 6 additions & 3 deletions testdata/summarize.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"MeanGrade": 13.21,
"StdDevGrade": 0.72,
"DaleChall": 9.51,
"ReadingEase": 47.29
"ReadingEase": 47.29,
"LIX": 54.06
},
{
"text": "Existing computer programs that measure readability are based largely upon subroutines which estimate number of syllables, usually by counting vowels. The shortcoming in estimating syllables is that it necessitates keypunching the prose into the computer. There is no need to estimate syllables since word length in letters is a better predictor of readability than word length in syllables. Therefore, a new readability formula was computed that has for its predictors letters per 100 words and sentences per 100 words. Both predictors can be counted by an optical scanning device, and thus the formula makes it economically feasible for an organization such as the U.S. Office of Education to calibrate the readability of all textbooks for the public school system.",
Expand All @@ -27,7 +28,8 @@
"MeanGrade": 16.34,
"StdDevGrade": 1.29,
"DaleChall": 12.19,
"ReadingEase": 24.14
"ReadingEase": 24.14,
"LIX": 59.09
},
{
"text": "He teaches science (He previously worked for 5 years as an engineer.) at the local University.",
Expand All @@ -42,6 +44,7 @@
"MeanGrade": 11.06,
"StdDevGrade": 2.03,
"DaleChall": 10.66,
"ReadingEase": 53.12
"ReadingEase": 53.12,
"LIX": 47.25
}
]

0 comments on commit 1210784

Please sign in to comment.