Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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 {
Expand Down