Andrea Sindico
Andrea Sindico

Reputation: 7440

CountVectorizer ignores Upper Case

What is the reason why CountVectorizer ignores word in upper case?

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

returns

[5, 3, 2, None, 1]

Upvotes: 2

Views: 1328

Answers (1)

cuuupid
cuuupid

Reputation: 1002

This is caused as lowercase is set to True by default in CountVectorizer, add lowercase=False.

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

Upvotes: 4

Related Questions