add code for counting words in training string