copy of code for calulating baseline bag of words method