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]
这是由于lowercase
在CountVectorizer
中默认设置为True
,添加lowercase=False
。
cv = CountVectorizer(stop_words=None, analyzer='word', token_pattern='.*',
max_features=None, lowercase=False)