word count


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: word count

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Posts
    11

    word count

    Hi everyone,
    I want to create a text file from the group of a documents. The text file should be organized into three colums where each row contains the document index, the word index, and the word count. For example:
    1 2 10
    1 3 4
    2 2 6
    should be read as "word 2 occurs 10 times in doc 1, word 3 occurs 4 times
    in doc 1, and word 2 occurs 6 times in doc 2".

    cheers
    Gulshan

  2. #2
    Join Date
    Mar 2004
    Posts
    78
    Hi,

    As far as I can see you want to:

    1. Create a list of all the words any of the files contain - this is how word 2 will mean something.
    2. you want to count the number of occurences of every word in the files.


    Well,

    Obviously you have to open the files and read the data from them.

    In a list you have to sotre the words that you have in your so called vocabulary(the different words in the file).
    Having the vocabulary you have to walk through the files one by one and create a map per file that holds the word as a key and the number of occurences of that file.

    Finally you have to print the contents of the maps in the result file:
    every map holds the results for a file, every word(map key) has a number that is the position of the word in the vocabuary and finaly you print the number of occurences.

    As probably you see all of this can be done in a single pass - single walk through the files:

    While reading from the files one by one you can make your vocabuary grow and in the same time make a single map hold tha number of occurences for the current file. At the end of the end of the file you write the results for the file. Then you open the next file, clear the map only and do the same.

    I hope I made it clear enough.

    If you do not know how to open files and read data - read a book about java, please

Similar Threads

  1. word count
    By hjhjhj in forum Java
    Replies: 2
    Last Post: 02-14-2006, 04:36 AM
  2. Need Help for a hook subclass issue in Word
    By hcadieu in forum VB Classic
    Replies: 0
    Last Post: 02-14-2006, 12:39 AM
  3. need to return total record count, but here is the trick...
    By barbarosa80503 in forum VB Classic
    Replies: 2
    Last Post: 10-28-2005, 03:33 PM
  4. Re: word count!!! Faster, Leaner, Meaner!
    By James World in forum .NET
    Replies: 0
    Last Post: 08-13-2001, 04:22 PM
  5. word count!!!
    By Jackee in forum .NET
    Replies: 2
    Last Post: 08-12-2001, 03:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center