Module: Hiq::Syllabizable
- Included in:
- Haiku, LineComposer, WordChecker
- Defined in:
- lib/hiq/syllabizable.rb
Overview
syllabization functionality
Instance Method Summary collapse
- #diphtongs(word) ⇒ Object
- #silent_e_count(word) ⇒ Object
- #syllables(word) ⇒ Object
- #triphtongs(word) ⇒ Object
Instance Method Details
#diphtongs(word) ⇒ Object
10 11 12 |
# File 'lib/hiq/syllabizable.rb', line 10 def diphtongs(word) word.downcase.scan(/(?:[^aeiouy]|^)([aeiouy][aeiouy])(?:[^aeiouy]|$)/).size end |
#silent_e_count(word) ⇒ Object
18 19 20 21 22 |
# File 'lib/hiq/syllabizable.rb', line 18 def silent_e_count(word) return 0 if word == 'the' word.downcase[-1] == 'e' ? 1 : 0 end |
#syllables(word) ⇒ Object
6 7 8 |
# File 'lib/hiq/syllabizable.rb', line 6 def syllables(word) word.downcase.scan(/[aeiouy]/).size - diphtongs(word) - triphtongs(word) - silent_e_count(word) end |
#triphtongs(word) ⇒ Object
14 15 16 |
# File 'lib/hiq/syllabizable.rb', line 14 def triphtongs(word) word.downcase.scan(/(?:[^aeiouy]|^)([aeiouy][aeiouy][aeiouy])([^aeiouy]|$)/).size end |