modified code to save/load the frequency along with the vocabulary when writing/reading model