Search in sources :

Example 56 with structures._Stn

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()];
            }
        }
    }
}
Also used : structures._Stn(structures._Stn) structures._SparseFeature(structures._SparseFeature)

Aggregations

structures._Stn (structures._Stn)46 structures._ChildDoc (structures._ChildDoc)33 structures._ParentDoc (structures._ParentDoc)27 structures._Doc (structures._Doc)22 HashMap (java.util.HashMap)19 File (java.io.File)17 PrintWriter (java.io.PrintWriter)17 structures._Word (structures._Word)16 FileNotFoundException (java.io.FileNotFoundException)15 structures._SparseFeature (structures._SparseFeature)12 structures._ParentDoc4DCM (structures._ParentDoc4DCM)6 Map (java.util.Map)5 structures._ChildDoc4BaseWithPhi (structures._ChildDoc4BaseWithPhi)4 ArrayList (java.util.ArrayList)3 IOException (java.io.IOException)2 ParseException (java.text.ParseException)2 TokenizeResult (structures.TokenizeResult)2 TreeMap (java.util.TreeMap)1 MyPriorityQueue (structures.MyPriorityQueue)1 structures._ChildDoc4BaseWithPhi_Hard (structures._ChildDoc4BaseWithPhi_Hard)1