use of structures._Stn in project IR_Base by Linda-sunshine.
the class HTSM method ComputeEmissionProbsForDoc.
@Override
// Construct the emission probabilities for sentences under different topics in a particular document.
void ComputeEmissionProbsForDoc(_Doc d) {
for (int i = 0; i < d.getSenetenceSize(); i++) {
_Stn stn = d.getSentence(i);
Arrays.fill(emission[i], 0);
int start = 0, end = this.number_of_topics;
if (i == 0 && d.getSourceType() == 2) {
// first sentence is specially handled for newEgg
// get the sentiment label of the first sentence
int sentimentLabel = stn.getStnSentiLabel();
if (sentimentLabel == 0) {
// positive sentiment in the first half
end = this.number_of_topics / 2;
for (int k = end; k < this.number_of_topics; k++) emission[i][k] = Double.NEGATIVE_INFINITY;
} else if (sentimentLabel == 1) {
// negative sentiment in the second half
start = this.number_of_topics / 2;
for (int k = 0; k < start; k++) emission[i][k] = Double.NEGATIVE_INFINITY;
}
}
for (int k = start; k < end; k++) {
for (_SparseFeature w : stn.getFv()) {
// all in log-space
emission[i][k] += w.getValue() * topic_term_probabilty[k][w.getIndex()];
}
}
}
}
Aggregations