Open a file and count vowels

Discussion in 'Java' started by Matt, Dec 30, 2006.

  1. Matt

    Matt Guest

    I am trying to create a program which will allow the user to open there
    desired text file and count the number of Vowels, and lines in the
    text. As of yet i cant find or dont know how to produce this program. I
    need to use Java was wondering if anyone has any ideas.
    Matt, Dec 30, 2006
    #1
    1. Advertising

  2. Matt <> wrote:

    > I am trying to create a program which will allow the user to open there
    > desired text file and count the number of Vowels, and lines in the
    > text. As of yet i cant find or dont know how to produce this program. I
    > need to use Java was wondering if anyone has any ideas.


    Use the classes and methods in the java.io package to open the file.
    Your friendly Java reference can tell you more. Read each line. Keep
    count. Look at each character and see if it's a vowel. Keep count.

    It should be beyond trivial for you to demonstrate 0.00001% effort and
    1) use Google as a source of information, 2) read your friendly
    textbook, and 3) try it yourself.

    --
    C. Benson Manica | I *should* know what I'm talking about - if I
    cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
    Christopher Benson-Manica, Dec 30, 2006
    #2
    1. Advertising

  3. Matt

    Daniel Pitts Guest

    Christopher Benson-Manica wrote:
    > Matt <> wrote:
    >
    > > I am trying to create a program which will allow the user to open there
    > > desired text file and count the number of Vowels, and lines in the
    > > text. As of yet i cant find or dont know how to produce this program. I
    > > need to use Java was wondering if anyone has any ideas.

    >
    > Use the classes and methods in the java.io package to open the file.
    > Your friendly Java reference can tell you more. Read each line. Keep
    > count. Look at each character and see if it's a vowel. Keep count.
    >
    > It should be beyond trivial for you to demonstrate 0.00001% effort and
    > 1) use Google as a source of information, 2) read your friendly
    > textbook, and 3) try it yourself.

    4) pay attention in class :)
    Daniel Pitts, Dec 31, 2006
    #3
  4. Matt

    jupiter Guest

    "Daniel Pitts" <> wrote in message
    news:...
    >
    > Christopher Benson-Manica wrote:
    >> Matt <> wrote:
    >>
    >> > I am trying to create a program which will allow the user to
    >> > open there
    >> > desired text file and count the number of Vowels, and lines in
    >> > the
    >> > text. As of yet i cant find or dont know how to produce this
    >> > program. I
    >> > need to use Java was wondering if anyone has any ideas.

    >>
    >> Use the classes and methods in the java.io package to open the
    >> file.
    >> Your friendly Java reference can tell you more. Read each line.
    >> Keep
    >> count. Look at each character and see if it's a vowel. Keep
    >> count.
    >>
    >> It should be beyond trivial for you to demonstrate 0.00001%
    >> effort and
    >> 1) use Google as a source of information, 2) read your friendly
    >> textbook, and 3) try it yourself.

    > 4) pay attention in class :)


    That was my problem. But then again, I did get the chick with the
    long legs so not all was lost.
    jupiter, Dec 31, 2006
    #4
  5. Matt

    Rhino Guest

    "Matt" <> wrote in message
    news:...
    >I am trying to create a program which will allow the user to open there
    > desired text file and count the number of Vowels, and lines in the
    > text. As of yet i cant find or dont know how to produce this program. I
    > need to use Java was wondering if anyone has any ideas.
    >


    You didn't mention what language the text file is using and that could make
    a difference. I'm not talking about the programming language which you are
    using to parse the text file, I'm talking about the language used in the
    text file.

    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.

    Now, I'm probably just overcomplicating the problem far beyond the
    intentions of your instructor but, if you are hoping to do a thorough job
    with this program, you may want to research this point and see if the
    definition of a vowel is sufficiently firm that you can apply it to any
    language you find in the text file that you are parsing. This could be worth
    serious brownie points if you can actually handle a multitude of languages
    and recognize the vowels in them regardless of the language chosen. :)

    --
    Rhino
    Rhino, Dec 31, 2006
    #5
  6. Matt

    Karl Uppiano Guest

    "Rhino" <> wrote in message
    news:en935n$hfr$...
    >
    > "Matt" <> wrote in message
    > news:...
    >>I am trying to create a program which will allow the user to open there
    >> desired text file and count the number of Vowels, and lines in the
    >> text. As of yet i cant find or dont know how to produce this program. I
    >> need to use Java was wondering if anyone has any ideas.
    >>

    >
    > You didn't mention what language the text file is using and that could
    > make a difference. I'm not talking about the programming language which
    > you are using to parse the text file, I'm talking about the language used
    > in the text file.
    >
    > 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.
    >
    > Now, I'm probably just overcomplicating the problem far beyond the
    > intentions of your instructor but, if you are hoping to do a thorough job
    > with this program, you may want to research this point and see if the
    > definition of a vowel is sufficiently firm that you can apply it to any
    > language you find in the text file that you are parsing. This could be
    > worth serious brownie points if you can actually handle a multitude of
    > languages and recognize the vowels in them regardless of the language
    > chosen. :)
    >
    > --
    > Rhino


    I thought Character.isVowel was localized! Ha ha ha!

    Man, I crack myself up...
    Karl Uppiano, Dec 31, 2006
    #6
  7. Matt

    mearvk Guest

    mearvk, Jan 1, 2007
    #7
  8. Matt

    Oliver Wong Guest

    [context is counting vowels in a text file]

    "Rhino" <> wrote in message
    news:en935n$hfr$...
    >
    > 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
    Oliver Wong, Jan 2, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil Slater
    Replies:
    8
    Views:
    1,093
    Howard
    May 17, 2004
  2. ivalki
    Replies:
    5
    Views:
    1,061
    Chris ( Val )
    Jan 16, 2007
  3. efelnavarro09
    Replies:
    2
    Views:
    929
    efelnavarro09
    Jan 26, 2011
  4. Dondi
    Replies:
    9
    Views:
    353
    Corey Haines
    Feb 2, 2008
  5. nwaits
    Replies:
    10
    Views:
    213
Loading...

Share This Page