def ngram_processor(items, ngram_len):
    '\n            Given a sequence or iterable of arbitrary items, return an iterator of\n            item ngrams tuples of length ngram_len. Buffers at most ngram_len iterable\n            items.\n\n            For example::\n\n            >>> list(ngram_processor([1, 2, 3, 4, 5], ngram_len=3))\n            [(1, 2, 3), (2, 3, 4), (3, 4, 5)]\n            '
    ngram = deque()
    current_len = 0
    for item in items:
        if (current_len == ngram_len):
            (yield tuple(ngram))
            ngram.popleft()
            current_len -= 1
        ngram.append(item)
        current_len += 1
    (yield tuple(ngram))
Given a sequence or iterable of arbitrary items, return an iterator of
item ngrams tuples of length ngram_len. Buffers at most ngram_len iterable
items.

For example::

>>> list(ngram_processor([1, 2, 3, 4, 5], ngram_len=3))
[(1, 2, 3), (2, 3, 4), (3, 4, 5)]
def ngram_processor(items, ngram_len):
    '\n            Given a sequence or iterable of arbitrary items, return an iterator of\n            item ngrams tuples of length ngram_len. Buffers at most ngram_len iterable\n            items.\n\n            For example::\n\n            >>> list(ngram_processor([1, 2, 3, 4, 5], ngram_len=3))\n            [(1, 2, 3), (2, 3, 4), (3, 4, 5)]\n            '
    ngram = deque()
    current_len = 0
    for item in items:
        if (current_len == ngram_len):
            (yield tuple(ngram))
            ngram.popleft()
            current_len -= 1
        ngram.append(item)
        current_len += 1
    (yield tuple(ngram))