Programming Contest
Problem F Pronunciation
Dr. Ceystuf N. Odwais, noted
linguistics expert, has proposed a set of rules for breaking any English
word into syllables. These rules assume that the word is examined
left to right, letter by letter. The rules are
-
The letters a e
i o u and y are regarded as vowels, with one exception
- y is regarded as a consonant is when it appears as the first
letter of a word.
-
For a syllable that begins with
a vowel, it will consist of consecutive letters up to and including
the first consonant encountered. Thus, in a word like "energy"
en
and er
are syllables or in a word like "odious" od
and ious
are syllables.
-
For a syllable that begins with
a consonant, it includes consecutive consonants, followed by consecutive
vowels. If the last vowel is followed by two or more consecutive
consonants, the first of these consonants is part of the syllable.
If the consonant following the last vowel is followed by a vowel, the syllable
ends with the last vowel. Thus, in a word like "extremely", the syllable
starting at the t includes only tre
because the consonant (m) is followed by a vowel. In the word "individual",
the syllable starting at the first d includes only di
because the v is followed by a vowel. But, in a word
like "membership", the syllable starting with the first m includes
mem
because the m is followed by b and the syllable starting at
the b includes ber
because the r is followed by s. And in a word like "crystal"
the first syllable is crys
because y is a vowel and s is followed by t. If there are no letters
after the last vowel, as in the last syllable of "energy" gy
then the syllable ends at the end of the word.
-
If after finding one or more
syllables in a word, the only letters that remain are vowels; then these
are taken as the last syllable. Thus, for the word "auxiliary",
the syllables are aux-il-iar-y..
If after finding one or more syllables in a word, the only letters that
remain are consonants, these letters should be made part of the previously
identified last syllable. For the word "stealth", the syllable found
would be steal
and the left over consonants should be added to it make stealth
a
single syllable word.
You are to write a program that
prompts for a line with words, the last word having a period at the end,
and then displays those words broken into syllables, one per line.
The program should use Dr. Odwais' rules to determine syllables.
The syllables should be separated with hyphens. Here is a sample
(Enter: is the prompt).
Enter: individual membership crystal select auxiliary stealth
onomatopoeia specify.
in-di-vi-dual
mem-ber-ship
crys-tal
se-lect
aux-il-iar-y
stealth
on-om-at-op-oeia
spe-ci-fy
Although Dr. Odwais' rules
work some of the time, they are far from perfect. Words with silent
e, th or ph combinations and others are often incorrectly broken into syllables.
Consider this example:
Enter: everything make father rhythm philosophy.
ev-er-yt-hing
ma-ke
fat-her
rhythm
phi-lo-sop-hy