title: Normalizing TF-IDF results
body: <p>I would like to normalize the tfidf results that I've got from this given code:</p>
  
  <pre><code>for (int docNum = 0; docNum &lt; ir.numDocs(); docNum++) {
              TermFreqVector tfv = ir.getTermFreqVector(docNum, "contents");
              if (tfv == null) {
                  // ignore empty fields
                  continue;
              }
              String[] tterms = tfv.getTerms();
              int termCount = tterms.length;
              int[] freqs = tfv.getTermFrequencies();
              for (int t = 0; t &lt; termCount; t++) {
                  double idf = ir.numDocs() / ir.docFreq(new Term("contents", tterms[t]));
                  System.out.println(" " + tterms[t] + " " + freqs[t]*Math.log(idf));
              }
          }
  </code></pre>
  
  <p>the output for this code is:</p>
  
  <pre><code>area 0.0
  areola 5.877735781779639
  ari 3.9318256327243257
  art 1.6094379124341003
  artifici 1.0986122886681098
  assign 2.1972245773362196
  associ 3.295836866004329
  assur 1.9459101490553132
  averag 1.0986122886681098
  avoid 0.6931471805599453
  .
  .
  .
  </code></pre>
  
  <p>Any help would be much appreciated. thank you</p>