Bag of words feature extraction