【发布时间】:2017-06-01 15:07:19
【问题描述】:
我有以下代码:
train_set = ("The sky is blue.", "The sun is bright.")
test_set = ("The sun in the sky is bright.",
"We can see the shining sun, the bright sun.")
现在我尝试像这样计算词频:
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer()
接下来我想打印词汇表。所以我这样做:
vectorizer.fit_transform(train_set)
print vectorizer.vocabulary
现在我没有得到任何输出。虽然我期望类似:
{'blue': 0, 'sun': 1, 'bright': 2, 'sky': 3}
有什么想法会出错吗?
【问题讨论】:
标签: python nlp text-mining