from sklearn.feature_extraction.text import CountVectorizer

# define a list of text documents
docs = ['this is the first document', 'this is the second document', 'and this is the third document']

# create a CountVectorizer object
vectorizer = CountVectorizer()

# fit the vectorizer to the documents and transform the documents into a bag-of-words representation
bow_matrix = vectorizer.fit_transform(docs)

# get the vocabulary of the bag-of-words representation
vocabulary = vectorizer.get_feature_names()

# print the bag-of-words representation and vocabulary
print(bow_matrix.toarray())
print(vocabulary)