title: How to extract keywords (tags) from text
body: <p>i am currently trying to implement a tagging engine in Java and searched for solutions to extract keywords/tag from texts (articles). I have found some solutions on stackoverflow suggesting to use Pointwise Mutual Information.</p>
  
  <p><a href="https://stackoverflow.com/questions/2764116/tag-generation-from-a-small-text-content-such-as-tweets">Solution 1</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2661778/tag-generation-from-a-text-content/2664351#2664351">Solution 2</a></p>
  
  <p>I cant use pyton and nltk so i have to implement it myself. But i dont know how to calculate the probabilities.
  The equation looks like this:</p>
  
  <pre><code>PMI(term, doc) = log [ P(term, doc) / (P(term)*P(doc)) ]
  </code></pre>
  
  <p>What i want to know is how to calculate P(term, doc)</p>
  
  <p>I already have a lange text corpus and a collection of articles. The articles are not part of the corpus. The corpus is indexed with lucene. </p>
  
  <p>Please help me out.
  Best regards.</p>