Count Syllables

Estimate the number of syllables in an English word.

Code

General
w = word.downcase.gsub(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '')
matches = w.scan(/[aeiouy]{1,2}/)
return matches.empty? ? 1 : matches.length

Parameters

Word to count syllables in

Server

More Ruby Snippets