python中的n克,四克,五克,六克?

python中的n克,四克,五克,六克?,第1张

python中的n克,四克,五克,六克?

其他用户提供的基于本地Python的出色答案。但是这就是

nltk
方法(以防万一,OP会因为重新发明
nltk
库中已经存在的内容而受到惩罚)。

有一个NGRAM模块,人们很少使用

nltk
。这不是因为很难读取ngram,而是基于ngram训练模型,其中n>
3将导致大量数据稀疏。

from nltk import ngramssentence = 'this is a foo bar sentences and i want to ngramize it'n = 6sixgrams = ngrams(sentence.split(), n)for grams in sixgrams:  print grams


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5601968.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存