int queryVector = 1;
double similarity = 0.0;
int wordPower;
for (a = 0; a < filename; a++) {
int totalwordPower = 0;
int totalWords = 0;
try {
System.out
.println(" _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ");
System.out.println("\n");
System.out.println("The word inputted : " + word2);
File file = new File(
"C:\\Users\\user\\fypworkspace\\TextRenderer\\abc" + a
+ ".txt");
System.out.println(" _________________");
System.out.print("| File = abc" + a + ".txt | \t\t \n");
for (int i = 0; i < array2.length; i++) {
totalCount = 0;
wordCount = 0;
Scanner s = new Scanner(file);
{
while (s.hasNext()) {
totalCount++;
if (s.next().equals(array2[i]))
wordCount++;
}
System.out.print(array2[i] + " --> Word count = "
+ "\t " + "|" + wordCount + "|");
System.out.print(" Total count = " + "\t " + "|"
+ totalCount + "|");
System.out.printf(" Term Frequency = | %8.4f |",
(double) wordCount / totalCount);
System.out.println("\t ");
double inverseTF = Math.log10((float) numDoc
/ (numofDoc[i]));
System.out.println(" --> IDF = " + inverseTF);
double TFIDF = (((double) wordCount / totalCount) * inverseTF);
System.out.println(" --> TF/IDF = " + TFIDF + "\n");
totalWords += wordCount;
wordPower = (int) Math.pow(wordCount, 2);
totalwordPower += wordPower;
System.out.println("Document Vector : " + wordPower);
similarity = (totalWords * queryVector)
/ ((Math.sqrt((totalwordPower)) * (Math
.sqrt(((queryVector * 3))))));
}
}
} catch (FileNotFoundException e) {
System.out.println("File is not found");
}
System.out.println("The total query frequency for this file is "
+ totalWords);
System.out.println("The total document vector : " + totalwordPower);
System.out.println("The similarity is " + similarity);
}
}
}
How do i display the calculated values automatically above into a table form ?
After the calculation, the data will be automatically mapped into a table.
each table for each data : Term frequency, IDF, word count, TF/IDF..
for example :
(Query)
Document "How" "are" "you"
abc01.txt values values values
abc02.txt " " "
abc03.txt " " "
abc04.txt " " "
abc05.txt
abc06.txt
abc07.txt
abc08.txt

New Topic/Question
Reply




MultiQuote







|