completed function that predicts words based on frequency counts