Class: Ari

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

Instance Method Summary collapse

Instance Method Details

#calc_score(letter_count, word_count, sentence_count) ⇒ Object



17
18
19
# 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

#nameObject



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

def name
  'Automated Readability Index'
end

#score(text, stats) ⇒ Object



3
4
5
# 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) ⇒ Object



7
8
9
10
11
12
13
14
15
# 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