title: Simple n-gram algorithm
body: <p>I am looking for an algorithm (or C#, Java source) that can find n-grams in sentences. Specifically, I have a vocabulary of 100 words (w1 to w100) and sentences composed of these words (s1, s2, s3 etc).</p>
  
  <p>The sentences are variable length from 1 to 100 words, the words can appear in any order in the sentence (but once placed in a sentence the order counts), the words can repeat any number of times.</p>
  
  <p>I am looking for an algorithm that will take a threshold number and return the n-grams in the sentences that occur above the threshold and the sentences in which the n-grams appear.</p>
  
  <p>I am also interested in a gap tolerant algorithm that finds common words in the same order but with gaps in between.</p>
  
  <p>Thanks in advance. I hope this question is stated clearly and within the scope of StackOverflow.</p>