gpt4 book ai didi

python - CountVectorizer 忽略大写

转载 作者:太空宇宙 更新时间:2023-11-04 09:55:13 27 4
gpt4 key购买 nike

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]

最佳答案

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

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

关于python - CountVectorizer 忽略大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46163345/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com