Would be great to point out which variant of Naive bayes you're implementing. This appears to be Multinomial Naive Bayes with frequency vectors as features.