It generates vocab based only on the second entry (a.k.a. category). Therefore, any tokens in text are unk, whose id is 0. IMO
You could write something similar like build_vocab_from_iterator 65. The constructor of the Vocab class needs a counter of tokens. Take a look at the Vocab class here 26