diff --git a/src/utils.h b/src/utils.h index fca7e0d..bba3f4f 100644 --- a/src/utils.h +++ b/src/utils.h @@ -194,6 +194,16 @@ inline void update_token_scores(std::vector< double >& scores, scale_token_weights(tokenWeights, normalizer, nTokens); } + std::vector< double > denominator_proportionalPol = std::vector< double >(nL, 0); + if (how == "proportionalPol") { + for (int j = 0; j < nL; j++) { + for (int i = 0; i < nTokens; i++) { + denominator_proportionalPol[j] += abs(tokenShifters[i] * tokenScores[i][j]); + } + } + } + + for (int i = 0; i < nTokens; i++) { // std::cout << "token: " << i << "\n"; for (int j = 0; j < nL; j++) { @@ -210,7 +220,8 @@ inline void update_token_scores(std::vector< double >& scores, } else if (how == "proportional") { scores[j] += (tokenShifters[i] * score) / (nTokens - nPuncts); } else if (how == "proportionalPol") { - if (nPolarized[j] > 0) scores[j] += (tokenShifters[i] * score) / nPolarized[j]; + // if (nPolarized[j] > 0) scores[j] += (tokenShifters[i] * score) / nPolarized[j]; + if (nPolarized[j] > 0) scores[j] += (tokenShifters[i] * score) / denominator_proportionalPol[j]; } else if (how == "proportionalSquareRoot") { scores[j] += (tokenShifters[i] * score) / std::sqrt(nTokens - nPuncts); } else {