Class: FleschKincaidRe

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

Instance Method Summary collapse

Instance Method Details

#calc_score(avg_words, avg_syllables) ⇒ Object



16
17
18
# File 'lib/odyssey/formulas/flesch_kincaid_re.rb', line 16

def calc_score(avg_words, avg_syllables)
  ((206.835 - (1.015 * avg_words)) - (84.6 * avg_syllables)).round(1)
end

#nameObject



20
21
22
# File 'lib/odyssey/formulas/flesch_kincaid_re.rb', line 20

def name
  'Flesch-Kincaid Reading Ease'
end

#score(text, stats) ⇒ Object



3
4
5
# File 'lib/odyssey/formulas/flesch_kincaid_re.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_re.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