def ngrams(string, n=3, punctuation=PUNCTUATION, **kwargs):
    s = string
    s = s.replace(".", " .")
    s = s.replace("?", " ?")
    s = s.replace("!", " !")
    s = [w.strip(punctuation) for w in s.split()]
    s = [w.strip() for w in s if w.strip()]
    return [tuple(s[i:i+n]) for i in xrange(len(s) - n + 1)]
Returns a list of n-grams (tuples of n successive words) from the given string.
dataset/ETHPy150Open clips/pattern/pattern/metrics.py/ngrams