SyllableCounter

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:

SyllableCounter.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 that will keep growing. Suggestions for additions are absolutely welcome! Email me at kelseymok@gmail.com.

  1. Assumes at least one obligatory vowel per syllable
  2. Final /e/ is not realized unless the final /e/ is preceded by an /l/ or /r/ and a consonant (ie. -dle, -cre).
  3. Final /ed/ suffix is not realized when preceeded by a /t/ or /d/
  4. Final /es/ plural suffix is realized after /s/ /z/ /sh/ /dg/ /ch/ /[aeiou]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. /iu/ combinations are two syllables
  3. Exceptions: "maybe", "Wednesday"
  4. Dialect-specific versions for English