title: Split a sentence into separate words
body: <p>I need to split a Chinese sentence into separate words. The problem with Chinese is that there are no spaces. For example, the sentence may look like: <code>主楼怎么走</code> (with spaces it would be: <code>主楼 怎么 走</code>).</p>
  
  <p>At the moment I can think of one solution. I have a dictionary with Chinese words (in a database). The script will:</p>
  
  <ol>
  <li><p>try to find the first two characters of the sentence in the database (<code>主楼</code>), </p></li>
  <li><p>if <code>主楼</code> is actually a word and it's in the database the script will try to find first three characters (<code>主楼怎</code>). <code>主楼怎</code> is not a word, so it's not in the database => my application now knows that <code>主楼</code> is a separate word.</p></li>
  <li><p>try to do it with the rest of the characters.</p></li>
  </ol>
  
  <p>I don't really like this approach, because to analyze even a small text it would query the database too many times.</p>
  
  <p>Are there any other solutions to this?</p>