code: def ngram_freq(text,N=1,log=False,floor=0.01):
      ''' returns the n-gram frequencies of all n-grams encountered in text.
          Option to return log probabilities or standard probabilities.
          Note that only n-grams occurring in 'text' will have probabilities.
          For the probability of not-occurring n-grams, use freq['floor'].
          This is set to floor/len(text) '''
      freq = ngram_count(text,N)
      L = 1.0*(len(text)-N+1)
      for c in freq.keys():
          if log: freq[c] = math.log10(freq[c]/L)
          else: freq[c] = freq[c]/L
      if log: freq['floor'] = math.log10(floor/L)
      else: freq['floor'] = floor/L   
      return fref ngram_freq(text,N=1,log=False,floor=0.01):
      ''' returns the n-gram frequencies of all n-grams encountered in text.
          Option to return log probabilities or standard probabilities.
          Note that only n-grams occurring in 'text' will have probabilities.
          For the probability of not-occurring n-grams, use freq['floor'].
          This is set to floor/len(text) '''
      freq = ngram_count(text,N)
      L = 1.0*(len(text)-N+1)
      for c in freq.keys():
          if log: freq[c] = math.log10(freq[c]/L)
          else: freq[c] = freq[c]/L
      if log: freq['floor'] = math.log10(floor/L)
      else: freq['floor'] = floor/L   
      return freq
docs: returns the n-gram frequencies of all n-grams encountered in text.
          Option to return log probabilities or standard probabilities.
          Note that only n-grams occurring in 'text' will have probabilities.
          For the probability of not-occurring n-grams, use freq['floor'].
          This is set to floor/len(text)