def ngram_count(text,N=<NUM_LIT:1>,keep_punct=False):
if not keep_punct: text = re.sub('<STR_LIT>','<STR_LIT>',text.upper())<EOL>count = {}<EOL>for i in range(len(text)-N+<NUM_LIT:1>):<EOL><INDENT>c = text[i:i+N]<EOL>if c in count: count[c] += <NUM_LIT:1><EOL>else: count[c] = <NUM_LIT:1.0><EOL><DEDENT>return count<EOL>
if N=1, return a dict containing each letter along with how many times the letter occurred.
        if N=2, returns a dict containing counts of each bigram (pair of letters)
        etc.
        There is an option to remove all spaces and punctuation prior to processing