def ngram_freq(text,N=<NUM_LIT:1>,log=False,floor=<NUM_LIT>):
freq = ngram_count(text,N)<EOL>L = <NUM_LIT:1.0>*(len(text)-N+<NUM_LIT:1>)<EOL>for c in freq.keys():<EOL><INDENT>if log: freq[c] = math.log10(freq[c]/L)<EOL>else: freq[c] = freq[c]/L<EOL><DEDENT>if log: freq['<STR_LIT>'] = math.log10(floor/L)<EOL>else: freq['<STR_LIT>'] = floor/L   <EOL>return freq<EOL>
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)