📅  最后修改于: 2022-03-11 14:46:28.426000             🧑  作者: Mango
from nltk import ngrams
sentence = 'this is a foo bar sentences and i want to ngramize it'
n = 6
sixgrams = ngrams(sentence.split(), n)
for grams in sixgrams:
print grams