Takes a string and returns the number of syllables.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install syllable-counter
To get the number of syllables for a string:
Syllables.get_syllables("Text to be evaluated goes here") #=> 10
The algorithm is not corpus-based but based upon phonemic complementary distributions as they exist in American English. This is an introductory set. Suggestions and exceptions are absolutely welcome! Email me at firstname.lastname@example.org.
- Assumes at least one obligatory vowel per syllable
- Final /e/ is not realized
- Final /ed/ suffix is not realized after being preceeded by a /t/ or /d/
- Final /es/ plural suffix is realized after /s/ /z/ /sh/ /dg/ /ch/ /[aeiouy]g/
- Two consecutive vowels outside of /[aeiouy]o/ are combined as one syllable
- /[aeiuy]o/ does not get merged as one syllable (ie. aon, ion, eon)
- Exceptions: "maybe", "Wednesday"
- Dialect-specific versions for English
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request