(s, n=4, out=False)
return (len(words), counts)
Takes a string as input and returns an object that can be given to
    either cook_refs or cook_test. This is optional: cook_refs and cook_test
    can take string arguments as well.
Takes a string as input and returns an object that can be given to
    either cook_refs or cook_test. This is optional: cook_refs and cook_test
    can take string arguments as well.
Takes a string as input and returns an object that can be given to either cook_refs or cook_test . This is optional : cook_refs and cook_test can take string arguments as well .
def precook(s, n=4, out=False):
    """Takes a string as input and returns an object that can be given to
    either cook_refs or cook_test. This is optional: cook_refs and cook_test
    can take string arguments as well."""
    words = s.split()
    counts = defaultdict(int)
    for k in xrange(1,n+1):
        for i in xrange(len(words)-k+1):
            ngram = tuple(words[i:i+k])
            counts[ngram] += 1
    return (len(words), counts)
def precook ( s , n = 4 , out = False ) : words = s . split ( ) counts = defaultdict ( int ) for k in xrange ( 1 , n + 1 ) : for i in xrange ( len ( words ) - k + 1 ) : ngram = tuple ( words [ i : i + k ] ) counts [ ngram ] += 1 return ( len ( words ) , counts )