word counter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sixstringstrumr
    New Member
    • Oct 2007
    • 3

    word counter

    Hi, I'm pretty new to java and programming and need some help with a program. I am trying to write a program that counts the words and syllables in a document. I was browsing through the API, but was unable to find anything caled "Word counter." I also need something that can count the sentences. Any ideas or suggestions would be greatly appreciated. Thanks so much!

    Eben
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    You will need to do this yourself. You need to read in the file line by line and determine how many words are in that line.

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by sixstringstrumr
      Hi, I'm pretty new to java and programming and need some help with a program. I am trying to write a program that counts the words and syllables in a document. I was browsing through the API, but was unable to find anything caled "Word counter." I also need something that can count the sentences. Any ideas or suggestions would be greatly appreciated. Thanks so much!

      Eben
      Have a look at this code.

      <snip>

      Don't spoonfeed code.

      Jos

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        @OP: For most West European languages the syllables part is extremely difficult
        to implement. Are you sure you want that?

        kind regards,

        Jos

        Comment

        • sixstringstrumr
          New Member
          • Oct 2007
          • 3

          #5
          Originally posted by dmjpro
          Have a look at this code.

          <snip>

          Don't spoonfeed code.

          Jos
          Thanks! I'll check it out in the API.

          Comment

          • sixstringstrumr
            New Member
            • Oct 2007
            • 3

            #6
            Originally posted by JosAH
            @OP: For most West European languages the syllables part is extremely difficult
            to implement. Are you sure you want that?

            kind regards,

            Jos
            Yes, unfortunately, I pretty much have to count the syllables. It goes into a formula to determine the "readabilit y" of a document. Thanks!

            Comment

            • Ganon11
              Recognized Expert Specialist
              • Oct 2006
              • 3651

              #7
              Originally posted by sixstringstrumr
              Yes, unfortunately, I pretty much have to count the syllables. It goes into a formula to determine the "readabilit y" of a document. Thanks!
              From what I remember of that assignment (and, yes, I did this assignment 2 years ago) there was some sort of 'shortcut' you were to use to count syllables. Something like - a word has a syllable for every vowel group you find separated by a consonant group. So "solid" has two syllables (an 'o' and an 'i' separated by an 'l'), "read" has one syllable ('ea' in one group), and "dreading" has two syllables ('ea' and 'i' separated by a 'd').

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by Ganon11
                From what I remember of that assignment (and, yes, I did this assignment 2 years ago) there was some sort of 'shortcut' you were to use to count syllables. Something like - a word has a syllable for every vowel group you find separated by a consonant group. So "solid" has two syllables (an 'o' and an 'i' separated by an 'l'), "read" has one syllable ('ea' in one group), and "dreading" has two syllables ('ea' and 'i' separated by a 'd').
                That 'shortcut' or 'heuristic' isn't perfect; counter example: "reappear".

                kind regards,

                Jos ( <--- nitpicker ;-)

                Comment

                • Ganon11
                  Recognized Expert Specialist
                  • Oct 2006
                  • 3651

                  #9
                  Originally posted by JosAH
                  That 'shortcut' or 'heuristic' isn't perfect; counter example: "reappear".

                  kind regards,

                  Jos ( <--- nitpicker ;-)
                  Yes, and that's why it's a shortcut, not a surefire thing. But remember, this assignment is supposed to be teaching programming, not grammar.

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by Ganon11
                    Yes, and that's why it's a shortcut, not a surefire thing. But remember, this assignment is supposed to be teaching programming, not grammar.
                    Syllables don't have much to do with grammar; it's more like a lexicology or
                    even phonetics thingy. But since it's a programming exercise I keep my mouth
                    shut about it ;-)

                    kind regards,

                    Jos

                    ps. @OP: pst! regular expressions are your friend here if you want to implement
                    that heuristic ... ;-)

                    Comment

                    • CodeTilYaDrop
                      New Member
                      • Aug 2007
                      • 66

                      #11
                      If you were in class the day the assignment was given, I remember the teacher saying something about an example of this code is in the last chapter we went over to our group.

                      Comment

                      Working...