title: How to compare many sentence in several documents in java
body: <p>I have several sentences in 2 documents who compare each other . I use formula similarity for comparing them and i use <code>List&lt;List&lt;&gt;&gt;</code>to get element sentences from documents. But it only works for 2 documents and doesn't work if i compare it more than three for example i compare 5 documents or more.</p>
  
  <p>The problem is how i get many sentence in several documents to compare them . </p>
  
  <p>Here is my code.</p>
  
  <pre><code>List&lt;List&lt;Sentence&gt;&gt; collect = Arrays.asList(new File(p).listFiles()).stream()
              .map((x) -&gt; configSentenceByLine(x.getAbsolutePath()))
              .map((x) -&gt; tokenizingWord(x))
              .map((x) -&gt; stemmingWord(x))
              .map((x) -&gt; countWordBased(x))
              .collect(Collectors.toList());
  
  for (int i = 0; i &lt; collect.get(0).size(); i++) {
          int mr = 1;
       for (int j = 0; j &lt; collect.get(1).size(); j++) {
            double sim = nc.getSimilarity(collect.get(0).get(i).getSentence(), collect.get(0+1).get(j+1).getSentence());
            System.out.println("Similarity = " + sim);
            mr++;
        }
  }
  </code></pre>
  
  <p>Sorry for my bad English</p>