Re: Open a file and count vowels
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Tue, 2 Jan 2007 17:48:13 -0500
[context is counting vowels in a text file]
"Rhino" <no.offline.contact.please@xxxxxxxxxx> wrote in message
news:en935n$hfr$1@xxxxxxxxxxxxxxxxxx
Even if the language used in the text file is always English and you
_know_ that it is always English, what do you do with the letter "y"? Is
it a vowel or a consonant? When I was in primary school, they taught that
the vowels were "a, e, i, o, u and _sometimes_ y". (I don't remember
anyone ever explaining when 'y' was considered a vowel and when it was
considered a consonant so I _suspect_ that the 'y' in "happy" is
considered a vowel but the 'y' in "yard" is considered a consonant without
really being remotely SURE.)
If the language in the text file isn't guaranteed to be English, the
problem gets much harder since you presumably don't know which language it
is. And while many languages are written using the same letters that we
use in English - sometimes with accents thrown in - those letters aren't
always pronounced the same as we pronounce them. So, in some cases, a
letter that might be a vowel to us could conceivably be a consonant in the
other language. (I can't actually think of an example of 'a', 'e', 'i',
'o' or 'u' being considered a consonant in some other language but it
seems possible that such a case could exist.) And once you get into
languages that don't use the English alphabet - like Russian or Chinese -
things get even crazier. I'm pretty sure Russian has letters that are
considered vowels - although I'm not sure which ones they are - but I'm
not at all sure if Chinese or Arabic or Hindi even has the concept of
vowels and consonants.
According to Wikipedia, it should be not be said that a given letter or
character is or is not a vowel, but rather a given *sound* may or may not be
a vowel. So as you point out, the letter 'y' maps onto different sounds,
depending on the surrounding letters, and in some cases, the sound it maps
onto happens to be a vowel, and in other cases, the sound it maps onto
happens to not be a vowel. The definition Wikipedia gives is "a vowel is a
sound in spoken language that is characterized by an open configuration of
the vocal tract so that there is no build-up of air pressure above the
glottis.".
So for example, the word "beet" contains a single vowel, represented by
the sequence of characters "ee", as opposed to containing two vowels. And
"W" is a vowel in Welsh, as is "V" in Creek. And if you had an arbitrary
stream of characters, for which the pronounciation was not well defined,
would it even be meaningful to ask about the number of vowels within that
stream? Does "QREA" contain one vowel, or two, or three, something else? It
probably depends on whether I, as the inventor of this word, declare its
pronounciation to be "Kwri", or "Kree Ah" or "Ku Wree Ay" or something else.
If this is a school assignment (and the subject under study is *not*
linguistics), then I'd assume the teacher simply wants the student to count
the number of occurrences of the letters "a", "e", "i", "o", "u"; And
whether or not "y" should be included would be clarified by the teacher.
- Oliver
.
- References:
- Re: Open a file and count vowels
- From: Rhino
- Re: Open a file and count vowels
- Prev by Date: Re: problem in java question
- Next by Date: Re: Unchecked call to compareTo
- Previous by thread: Re: Open a file and count vowels
- Next by thread: Re: Open a file and count vowels
- Index(es):
Relevant Pages
|