为什么print nltk.ConditionalFreqDist表格的输出中没有?

2024-06-25 22:58:03 发布

您现在位置:Python中文网/ 问答频道 /正文

使用Anaconda Spyder、Python 3.8.3、nltk 3.5。代码和输出如下所示:

from nltk.corpus import reuters
cfd = [('gas', word) for word in brown.words(categories='gas')]
print(cfd.tabulate(conditions=['gas'], samples=['gasoline', 'barrels']))

----------------
Output:
    gasoline  barrels 
gas       77       64 
None

如何才能从此输出中删除任何内容?

FYI - None is not in output when I use Jupyter notebook as below:

cfd = [('gas', word) for word in brown.words(categories='gas')]
cfd.tabulate(conditions=['gas'], samples=['gasoline', 'barrels']

----------------
Output:
    gasoline  barrels 
gas       77       64

Tags: inforoutputconditionswordcategorieswordstabulate