Class: Gunning_fog
Instance Method Summary collapse
- #calc_score(avg_words, percent_with_three) ⇒ Object
- #name ⇒ Object
- #score(text, stats) ⇒ Object
-
#three_syllables(word_count, syllables) ⇒ Object
percentage of words with three syllables.
Instance Method Details
#calc_score(avg_words, percent_with_three) ⇒ Object
17 18 19 |
# File 'lib/formulas/gunning_fog.rb', line 17 def calc_score(avg_words, percent_with_three) ((avg_words + percent_with_three) * 0.4).round(1) end |
#name ⇒ Object
21 22 23 |
# File 'lib/formulas/gunning_fog.rb', line 21 def name 'Gunning-Fog Score' end |
#score(text, stats) ⇒ Object
3 4 5 6 |
# File 'lib/formulas/gunning_fog.rb', line 3 def score(text, stats) percent = three_syllables(stats['word_count'], text['syllables']) calc_score(stats['average_words_per_sentence'], percent) end |
#three_syllables(word_count, syllables) ⇒ Object
percentage of words with three syllables
9 10 11 12 13 14 15 |
# File 'lib/formulas/gunning_fog.rb', line 9 def three_syllables(word_count, syllables) with_three = 0 syllables.each do |s| with_three += 1 if s > 2 end (with_three / word_count) * 100 end |