Exercise 1: Building the Bag-of-Words Vector for "free call now" — Possible Solution ==================================================================== THE ESTABLISHED VOCABULARY, PER THIS CHAPTER ------------------------------ Per this chapter's own worked example, the vocabulary built from "free money now" and "call me now" is, in order: [call, free, me, money, now] — five unique words, each assigned a fixed position in every vector. COUNTING EACH VOCABULARY WORD IN "free call now" ------------------------------ Going through the vocabulary in the same fixed order and counting how many times each word appears in "free call now": - call: appears once → 1 - free: appears once → 1 - me: does not appear → 0 - money: does not appear → 0 - now: appears once → 1 THE RESULTING VECTOR ------------------------------ [1, 1, 0, 0, 1] WHY EACH POSITION GETS ITS SPECIFIC VALUE ------------------------------ Per this chapter's own definition, "represent each document as a vector with one position per vocabulary word, where the value is how many times that word appears in that document." Each of the five positions in the vector corresponds to exactly one of the five vocabulary words, in the same fixed order established when the vocabulary was first built — the value placed at each position is simply a direct count of how many times that specific word occurs in the new document "free call now," regardless of the order those words actually appear in. WHY THE VOCABULARY ITSELF DOESN'T CHANGE FOR A NEW DOCUMENT ------------------------------ The vocabulary was already fixed once, from the original two training documents — this new document, "free call now," happens to use only words already present in that vocabulary (call, free, now), so every word in it has a defined position to be counted into. If this new document had included a word never seen in the original vocabulary (per this chapter's own later section on unseen words), that word would have had nowhere to be counted at all and would simply be dropped. WHY THIS WORKS AS AN ANSWER ------------------------------ It applies the chapter's own fixed, ordered vocabulary directly to the new document, counts each vocabulary word's own occurrences one by one, and explains precisely why each position in the resulting vector receives the specific value it does.