Replies To: how to display calculated values in table form ?

Re: how to display calculated values in table form ?

Posted 18 March 2011 - 02:03 PM

It's hard to understand what you're trying to do from your "example." You talk about mapping the results to a table but then give a list of 7 text files that have no discernible relationship to the data or document. Can you expand on what you're trying to do?

Re: how to display calculated values in table form ?

Posted 18 March 2011 - 11:38 PM

i am sorry for my poor display of my question. Basically i am trying to calculate all the occurrence of each query words in a text file. By calculating the frequency of each query words, i have managed to calculate the term frequency and inverse term frequency for each words of each text files. What i wanted to do is, i wanted to display a much user readable data in the form of table depicting the scores for each text files. Let me show you what is my current output.
This is the example run of first file.

Document Vector : 0
The total query frequency for this file is 0
The total document vector : 0
The similarity is NaN

As you see, each words has their own word count, term total count, term frequency, IDF, TF/IDF.

What i wanted to do is to display the score in table form for each word count, term total count, term frequency, IDF, TF/IDF and the similarity. I couldn't figure how to display the scores for each in table form.

where x, y, and z represent the number of times the words a, b, and c were found in the files in column 1?

If so, this is a fairly simple task to program. Roughly:
open each file for reading,
read each word in the file,
determine if the word is a, b, or c,
increment a, b, or c counters in 2D array (file -vs- word count) as words are found,
close file,
repeat read file/count words until all files are read,
output results.

Start coding that, taking it a step at a time, breaking it down into smaller steps if necessary, and come back for help when needed.

Now that I've read your last post in this thread, I think my table above could still be used but there would be more columns for the other data you wanted to tabulate. For example, based on your response, it would look something like:

Is that what you have in mind? Again, not that hard (though it may seem so to you, so I apologize if I'm over simplifying), but you'll follow (roughly) the same steps I outlined above and then use a formatted print statement to present the data in a table format.

In general, if a project seems too hard, break it down into the smallest possible pieces and design/code each piece at a time, sometimes breaking those even further down, as needed, to reduce complexity. Eventually, you'll get to pieces that seem easily accomplished, and the whole project won't seem so daunting.

Re: how to display calculated values in table form ?

Posted 19 March 2011 - 12:28 PM

Your problem lies here System.out.println(testData);. Arrays do not override the Object toString() method, so when you print them, you get the hash code output. You need to print out each element individually rather than an array.