📜  从文本 python 代码示例中提取 n 克

📅  最后修改于: 2022-03-11 14:46:28.426000             🧑  作者: Mango

代码示例1
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