from sklearn.feature_extraction.text import CountVectorizer bow_vectorizer = CountVectorizer() bow_matrix = bow_vectorizer.fit_transform(documents)