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();
}
}
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;
}
Aggregations