TLP - Programming Maintenance
Week 5 - Estimating syllables in a word

Background

If you have taught elementary school or have had kids go through one recently, you are probably familiar with AR scores. These are the estimates for what grade level a book is targeted for. For example:

The first number represents the grade level and the second number represents how far into the school year the book is appropriate. So "Green Eggs and Ham would be appropriate halfway through first grade and Moby Dick is appropriate towards the start of 10th grade.

We aren't ready to calculate that full score (we will attempt that in week 14). But this week we can take the first part - estimating how many syllables are in a single word.

While this is complicated in theory, there is actually a technique that is fairly accurate:

  1. Count the number of vowels or vowel "clusters" in the word (including y).
    • In other words, a vowel on it's own is 1 and the first vowel in a string of vowels counts as 1
    • The other way to look at this is you should NOT count a vowel if it comes after another vowel
  2. Do not count an ā€œeā€ at the end of a word
  3. Do not return a score of 0. Always return at least a 1.

 

Task

 

Hints