jennyong220 / pwp-capstones

0 stars 0 forks source link

n_gram_creator #1

Open ad3429 opened 5 years ago

ad3429 commented 5 years ago

Your n_gram_creator works fine how you have it, but here is another way to write it using a foreach loop in case you want to take a look:

def ngram_creator(text_list):
    ngrams   = []
    lastword = None

    for word in text_list:
        if lastword:
            ngrams.append('{} {}'.format(lastword, word))
        lastword = word
    return ngrams
jennyong220 commented 5 years ago

ooo, that's interesting. Thanks for the perspective!