def word_pairs(text):
    last_word = None

    for word in words(text):
        if last_word is not None:
            yield last_word, word
        last_word = word

    yield last_word, "<end>"
Given some text, yield out pairs of words (eg bigrams).
dataset/ETHPy150Open Yelp/dataset-examples/review_autopilot/autopilot.py/word_pairs