Syllable-Counter

Takes a string and returns the number of syllables.

Installation

Add this line to your application's Gemfile:

gem 'syllable-counter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install syllable-counter 

Usage

To get the number of syllables for a string:

Syllables.get_syllables("Text to be evaluated goes here")
#=> 10

Algorithm

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 kelseymok@gmail.com.

  1. Assumes at least one obligatory vowel per syllable
  2. Final /e/ is not realized
  3. Final /ed/ suffix is not realized after being preceeded by a /t/ or /d/
  4. Final /es/ plural suffix is realized after /s/ /z/ /sh/ /dg/ /ch/ /[aeiouy]g/
  5. Two consecutive vowels outside of /[aeiouy]o/ are combined as one syllable

Pending

  1. /[aeiuy]o/ does not get merged as one syllable (ie. aon, ion, eon)
  2. Exceptions: "maybe", "Wednesday"
  3. Dialect-specific versions for English

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request