Counting syllables
807591Apr 3 2008 — edited Apr 5 2008In order to count the syllables in the text one counts the vowels. I have done this as follows:
//count the vowels(including y)in the extract,vowels represent the syllables
for (int i=0;i<extract.length();i++)
{
char letter=extract.charAt(i);
if((letter=='a')||(letter=='A')||
(letter=='e')||(letter=='E')||
(letter=='i')||(letter=='I')||
(letter=='o')||(letter=='O')||
(letter=='u')||(letter=='U')||
(letter=='y')||(letter=='Y'))
{
syllableCount++;
}
}
If a word has an 'e' on the end like 'rage' then it must not be included in the syllable count. I am having problems with this part. I have tried the following but it does not work:
for (int i=0;i<extract.length();i++)
{
char endLetter=extract.charAt(i);
char endLetter2=extract.charAt(i-1);
if ((endLetter==' ')&&(endLetter2=='e'))
{
syllableCount--;
}
}