From 91f1cca9c0dfc7ab056d663fe9dfbe800a68c269 Mon Sep 17 00:00:00 2001 From: odelmarcelle Date: Fri, 3 Dec 2021 14:44:47 +0100 Subject: [PATCH] change denominator computation for proportionalPol --- src/utils.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 {