Class: FleschKincaidGl

Inherits:
Odyssey::Formula show all
Defined in:
lib/odyssey/formulas/flesch_kincaid_gl.rb

Instance Method Summary collapse

Instance Method Details

#calc_score(avg_words, avg_syllables) ⇒ Object



17
18
19
# File 'lib/odyssey/formulas/flesch_kincaid_gl.rb', line 17

def calc_score(avg_words, avg_syllables)
  (((0.39 * avg_words) + (11.8 * avg_syllables)) - 15.59).round(1)
end

#nameObject



21
22
23
# File 'lib/odyssey/formulas/flesch_kincaid_gl.rb', line 21

def name
  'Flesch-Kincaid Grade Level'
end

#score(text, stats) ⇒ Object



3
4
5
# File 'lib/odyssey/formulas/flesch_kincaid_gl.rb', line 3

def score(text, stats)
  calc_score(stats['average_words_per_sentence'], stats['average_syllables_per_word'])
end

#score_by_sentence(text, stats_split) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/odyssey/formulas/flesch_kincaid_gl.rb', line 7

def score_by_sentence(text, stats_split)
  res = []
  for i in 0..text['sentences'].length-1
    res.push(calc_score(stats_split['word_count'][i],
                        stats_split['average_syllables_per_word'][i]))
  end
  res
end