title: Cosine Similarity
body: <p>I calculated tf/idf values of two documents. The following are the tf/idf values: </p>
  
  <pre><code>1.txt
  0.0
  0.5
  2.txt
  0.0
  0.5
  </code></pre>
  
  <p>The documents are like:</p>
  
  <pre><code>1.txt = &gt; dog cat
  2.txt = &gt; cat elephant
  </code></pre>
  
  <p><em>How can I use these values to calculate cosine similarity?</em></p>
  
  <p>I know that I should calculate the dot product, then find distance and divide dot product by it. How can I calculate this using my values?</p>
  
  <p>One more question: <em>Is it important that both documents should have same number of words?</em></p>