title: How to generate n-grams in scala?
body: <p>I am trying to code dissociated press algorithm based on n-gram in scala. 
  How to generate an n-gram for a large files:
  For example, for the file containing "the bee is the bee of the bees". </p>
  
  <ol>
  <li>First it has to pick a random n-gram. For example, the bee.</li>
  <li>Then it has to look for n-grams starting with (n-1) words. For example, bee of.</li>
  <li>it prints the last word of this n-gram. Then repeats. </li>
  </ol>
  
  <p>Can you please give me some hints how to do it?
  Sorry for the inconvenience. </p>