CountVectorizer忽略大写

时间:2017-09-11 19:47:47

标签: python pandas numpy scikit-learn

CountVectorizer忽略大写单词的原因是什么?

cv = CountVectorizer(stop_words=None,analyzer='word',token_pattern='.*',max_features=None)
text = ['this','is','a','Test','!']
fcv = cv.fit_transform(list)
fcv = [cv.vocabulary_.get(t) for t in text]
print fcv

返回

[5, 3, 2, None, 1]

1 个答案:

答案 0 :(得分:4)

这是因为lowercase默认设置为True CountVectorizer,添加lowercase=False

cv = CountVectorizer(stop_words=None, analyzer='word', token_pattern='.*',
        max_features=None, lowercase=False)