Bag of words models (i.e. term-document matrix creation) in Javascript