Code QuizIntermediate Constructing a Bag-of-Words Vector
Find why repeated words don't increase this bag-of-words count.
Codepython
vocab = {"nlp": 0, "is": 1, "fun": 2}
sentence = "nlp is nlp fun"
vector = [0] * len(vocab)
for word in sentence.split():
vector[vocab[word]] = 1
print(vector) # expecting countsWhat is the bug in this bag-of-words construction?