class ColemanLiau
Public Instance Methods
calc_score(letter_count, word_count, sentence_count)
click to toggle source
# File lib/odyssey/formulas/coleman_liau.rb, line 16 def calc_score(letter_count, word_count, sentence_count) ((5.89 * (letter_count.to_f / word_count.to_f)) - (0.3 * (sentence_count.to_f / word_count.to_f)) - 15.8).round(1) end
name()
click to toggle source
# File lib/odyssey/formulas/coleman_liau.rb, line 20 def name 'Coleman-Liau Index' end
score(text, stats)
click to toggle source
# File lib/odyssey/formulas/coleman_liau.rb, line 3 def score(text, stats) calc_score(stats['letter_count'], stats['word_count'], stats['sentence_count']) end
score_by_sentence(text, stats_split)
click to toggle source
# File lib/odyssey/formulas/coleman_liau.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['letter_count'][i], stats_split['word_count'][i], 1)) end end