Module: Algorithms
- Defined in:
- lib/algorithms.rb
Class Method Summary collapse
- .grade(sentences, words, syllables) ⇒ Object
- .syllable_count(word) ⇒ Object
- .wiener_sachtextformel(sentences, words, ms) ⇒ Object
Class Method Details
.grade(sentences, words, syllables) ⇒ Object
14 15 16 |
# File 'lib/algorithms.rb', line 14 def self.grade sentences, words, syllables (0.39 * (words / sentences) + 11.8 * (syllables / words) - 15.59).round(2) end |
.syllable_count(word) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/algorithms.rb', line 2 def self.syllable_count word # see https://stackoverflow.com/questions/1271918/ruby-count-syllables word.downcase! return 1 if word.length <= 3 word.sub!(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '') word.sub!(/^y/, '') word.scan(/[aeiouy]{1,2}/).size end |
.wiener_sachtextformel(sentences, words, ms) ⇒ Object
10 11 12 |
# File 'lib/algorithms.rb', line 10 def self.wiener_sachtextformel sentences, words, ms (0.2656 * (words / sentences) + 0.2744 * ms -1.693).round(2) end |