word count program???

Discussion in 'Computer Science & Culture' started by suppy, Mar 15, 2003.

Thread Status:
Not open for further replies.
  1. suppy Registered Member

    Messages:
    1
    Hi guys... I am having a problem with the word count program. I have to write a program that asks for and brings up a text file and then lists all the words in that file and how many times each word has occured. I need to submitt the program on monday(17/03/2003).

    I will be so grateful if someone reply to this message.

    Please Register or Log in to view the hidden image!

     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. AntonK Technomage Registered Senior Member

    Messages:
    1,083
    pretty easy concept...tokenize the entire document by the space character and the period (and any other silly little punctuations). Then go through them one by one, using lists. one is of type string (char* whatever ur language) and other is int. For everyone of your tokenized words, look in your string list. If it is there then do a ++ on that index in the integer array. If it is not in there, add it to the list of strings and put its number in the integer array to 1.

    Example
    <code>
    I am parsing. Parsing is fun. I like fun.

    2 I
    1 am
    2 parsing
    1 is
    2 fun
    1 like
    </code>

    Anton K
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
Thread Status:
Not open for further replies.

Share This Page