Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed help on understanding of this guide
    primarykey
    data
    text
    <p>this guide is given by one of my lecturer and i wanted to implement in java. But i do not quite understand it though on how to implement in on java. Can someone try to explain it further for me? I appreciate a good tutorial though. :)</p> <p>"Create an array for the text file, look through each text file for the term, once you got the term, you break the inner loop, change the file name and loop again to search for the term. then create a counter to count the number of text file that contain the term. Lastly you will get the number of document containing the term from the counter value."</p> <p>I has a collection of text files where i need to check whether a specific term is found on the file. If the term is found, i need to increment the fileFound to 1. </p> <p>Or more specifically inverse document frequency. </p> <p>What do i need in order to achieve the above ? I mean in code perspective. Sorry, i am slow in codings. No, i do not wish for free codes. I just want to understand what the guide is given. I have asked my lecturer but it does not sufficient though. I just wanted to know how to implement in java. Thanks for your time. </p> <pre><code>System.out.println("Please enter the required word :"); Scanner scan2 = new Scanner(System.in); String word2 = scan.nextLine(); String[] array2 = word2.split(" "); int numofDoc = 0; for (int i = 0; i &lt; filename; i++) { for (int b = 0; b &lt; array2.length; b++) { try { BufferedReader in = new BufferedReader(new FileReader( "C:\\Users\\user\\fypworkspace\\TextRenderer\\abc" + i + ".txt")); int matchedWord = 0; Scanner s2 = new Scanner(in); { while (s2.hasNext()) { if (s2.next().contains(word2)) matchedWord++; } } if (matchedWord &gt; 0) numofDoc++; System.out.println("This file contain the term " + numofDoc); } catch (IOException e) { System.out.println("File not found."); } } } </code></pre> <p>The output is :</p> <p>Please enter the required word :</p> <pre><code>the File containing the term is 1 File containing the term is 1 File containing the term is 1 File containing the term is 1 File containing the term is 1 File containing the term is 1 File not found File containing the term is 1 File containing the term is 1 File containing the term is 1 File containing the term is 1 </code></pre> <p>i would like the output to printout single output which shows number of File containing the term is 10. It means it already sum up the total. And only print one line out in the output. Any idea sir ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload