title: TFIDF calculating confusion
body: <p>I found the following code on the internet for calculating TFIDF:</p>
  
  <pre><code>https://github.com/timtrueman/tf-idf/blob/master/tf-idf.py
  </code></pre>
  
  <p>I added "1+" in the function def idf(word, documentList) so i won't get divided by 0 error:</p>
  
  <pre><code>return math.log(len(documentList) / (1 + float(numDocsContaining(word,documentList))))
  </code></pre>
  
  <p>But i am confused for two things:</p>
  
  <ol>
  <li>I get negative values in some cases, is this correct?</li>
  <li>I am confused with line 62, 63 and 64.</li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code> documentNumber = 0
    for word in documentList[documentNumber].split(None):
         words[word] = tfidf(word,documentList[documentNumber],documentList)
  </code></pre>
  
  <p>Should TFIDF be calculated on the first document only?</p>