title: LSA - Latent Semantic Analysis - How to code it in PHP?
body: <p>I would like to implement Latent Semantic Analysis (LSA) in PHP in order to find out topics/tags for texts.</p>
  
  <p>Here is what I think I have to do. <strong>Is this correct? How can I code it in PHP? How do I determine which words to chose?</strong></p>
  
  <p>I don't want to use any external libraries. <a href="https://stackoverflow.com/questions/960060/singular-value-decomposition-svd-in-php">I've already an implementation for the Singular Value Decomposition (SVD)</a>.</p>
  
  <ol>
  <li>Extract all words from the given text.</li>
  <li>Weight the words/phrases, e.g. with <a href="http://en.wikipedia.org/wiki/Tf%E2%80%93idf" rel="nofollow noreferrer">tf–idf</a>. If weighting is too complex, just take the number of occurrences.</li>
  <li>Build up a matrix: The columns are some documents from the database (the more the better?), the rows are all unique words, the values are the numbers of occurrences or the weight.</li>
  <li>Do the Singular Value Decomposition (SVD).</li>
  <li>Use the values in the matrix S (SVD) to do the dimension reduction (how?).</li>
  </ol>
  
  <p>I hope you can help me. Thank you very much in advance!</p>