Search in sources :

Example 16 with structures._ChildDoc4BaseWithPhi

use of structures._ChildDoc4BaseWithPhi in project IR_Base by Linda-sunshine.

the class ACCTM_C_test method printXProportion.

public void printXProportion(String xProportionFile, ArrayList<_Doc> docList) {
    System.out.println("x proportion for parent doc");
    try {
        PrintWriter pw = new PrintWriter(new File(xProportionFile));
        for (_Doc d : docList) {
            if (d instanceof _ParentDoc) {
                for (_ChildDoc doc : ((_ParentDoc) d).m_childDocs) {
                    _ChildDoc4BaseWithPhi cDoc = (_ChildDoc4BaseWithPhi) doc;
                    pw.print(d.getName() + "\t");
                    pw.print(cDoc.getName() + "\t");
                    pw.print(cDoc.m_xProportion[0] + "\t");
                    pw.print(cDoc.m_xProportion[1]);
                    pw.println();
                }
            }
        }
        pw.flush();
        pw.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : structures._ChildDoc4BaseWithPhi(structures._ChildDoc4BaseWithPhi) structures._ChildDoc(structures._ChildDoc) structures._Doc(structures._Doc) structures._ParentDoc(structures._ParentDoc) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) PrintWriter(java.io.PrintWriter)

Example 17 with structures._ChildDoc4BaseWithPhi

use of structures._ChildDoc4BaseWithPhi in project IR_Base by Linda-sunshine.

the class corrLDA_Gibbs method cal_logLikelihood_partial4Child.

protected double cal_logLikelihood_partial4Child(_Doc d) {
    // _ChildDoc4BaseWithPhi cDoc = (_ChildDoc4BaseWithPhi)d;
    double docLogLikelihood = 0.0;
    for (_Word w : d.getTestWords()) {
        int wid = w.getIndex();
        double wordLogLikelihood = 0;
        for (int k = 0; k < number_of_topics; k++) {
            double term1 = d.m_topics[k];
            double term2 = topic_term_probabilty[k][wid];
            // double term1 = childWordByTopicProb(k, wid);
            // double term2 = childTopicInDoc(k, d);
            double wordPerTopicLikelihood = term1 * term2;
            wordLogLikelihood += wordPerTopicLikelihood;
        }
        if (Math.abs(wordLogLikelihood) < 1e-10) {
            System.out.println("wordLoglikelihood\t" + wordLogLikelihood);
            wordLogLikelihood += 1e-10;
        }
        wordLogLikelihood = Math.log(wordLogLikelihood);
        docLogLikelihood += wordLogLikelihood;
    }
    return docLogLikelihood;
}
Also used : structures._Word(structures._Word)

Aggregations

structures._ChildDoc4BaseWithPhi (structures._ChildDoc4BaseWithPhi)15 structures._Word (structures._Word)10 structures._ParentDoc (structures._ParentDoc)9 structures._ChildDoc (structures._ChildDoc)7 structures._Doc (structures._Doc)4 structures._Stn (structures._Stn)4 File (java.io.File)2 structures._SparseFeature (structures._SparseFeature)2 FileNotFoundException (java.io.FileNotFoundException)1 PrintWriter (java.io.PrintWriter)1 JSONObject (json.JSONObject)1