class Ari

Public Instance Methods

calc_score(letter_count, word_count, sentence_count) click to toggle source
# File lib/odyssey/formulas/ari.rb, line 17
def calc_score(letter_count, word_count, sentence_count)
  (((4.71 * (letter_count.to_f / word_count.to_f)) + (0.5 * (word_count.to_f / sentence_count.to_f))) - 21.43).round(1)
end
name() click to toggle source
# File lib/odyssey/formulas/ari.rb, line 21
def name
  'Automated Readability Index'
end
score(text, stats) click to toggle source
# File lib/odyssey/formulas/ari.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/ari.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
  res
end