use of structures._Word in project IR_Base by Linda-sunshine.
the class ACCTM_test method printChildTopicAssignment.
protected void printChildTopicAssignment(_Doc d, File topicFolder) {
// System.out.println("printing topic assignment parent documents");
String topicAssignmentFile = d.getName() + ".txt";
try {
PrintWriter pw = new PrintWriter(new File(topicFolder, topicAssignmentFile));
for (_Word w : d.getWords()) {
int index = w.getIndex();
int topic = w.getTopic();
String featureName = m_corpus.getFeature(index);
pw.print(featureName + ":" + topic + "\t");
}
pw.flush();
pw.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of structures._Word in project IR_Base by Linda-sunshine.
the class DCMCorrLDA method cal_logLikelihood_partial4Child.
protected double cal_logLikelihood_partial4Child(_ChildDoc cDoc) {
double childLikelihood = 0;
_ParentDoc4DCM pDoc = (_ParentDoc4DCM) cDoc.m_parentDoc;
for (_Word w : cDoc.getTestWords()) {
int wid = w.getIndex();
double wordLogLikelihood = 0;
for (int k = 0; k < number_of_topics; k++) {
double wordPerTopicLikelihood = cDoc.m_topics[k] * pDoc.m_wordTopic_prob[k][wid];
wordLogLikelihood += wordPerTopicLikelihood;
}
childLikelihood += Math.log(wordLogLikelihood);
}
return childLikelihood;
}
use of structures._Word in project IR_Base by Linda-sunshine.
the class DCMCorrLDA method initTest.
protected void initTest(ArrayList<_Doc> sampleTestSet, _Doc d) {
_ParentDoc4DCM pDoc = (_ParentDoc4DCM) d;
for (_Stn stnObj : pDoc.getSentences()) {
stnObj.setTopicsVct(number_of_topics);
}
int testLength = 0;
pDoc.setTopics4GibbsTest(number_of_topics, 0, testLength, vocabulary_size);
sampleTestSet.add(pDoc);
for (_ChildDoc cDoc : pDoc.m_childDocs) {
testLength = (int) (m_testWord4PerplexityProportion * cDoc.getTotalDocLength());
cDoc.setTopics4GibbsTest(number_of_topics, d_alpha, testLength);
for (_Word w : cDoc.getWords()) {
int wid = w.getIndex();
int tid = w.getTopic();
pDoc.m_wordTopic_stat[tid][wid]++;
pDoc.m_topic_stat[tid]++;
}
sampleTestSet.add(cDoc);
cDoc.createSparseVct4Infer();
// cDoc computeMu
computeTestMu4Doc(cDoc);
}
}
use of structures._Word in project IR_Base by Linda-sunshine.
the class DCMCorrLDA_multi_E_test method rankChild4StnByLikelihood.
protected HashMap<String, Double> rankChild4StnByLikelihood(_Stn stnObj, _ParentDoc4DCM pDoc) {
HashMap<String, Double> likelihoodMap = new HashMap<String, Double>();
for (_ChildDoc cDoc : pDoc.m_childDocs) {
double stnLogLikelihood = 0;
for (_Word w : stnObj.getWords()) {
double wordLikelihood = 0;
int wid = w.getIndex();
for (int k = 0; k < number_of_topics; k++) {
wordLikelihood += cDoc.m_topics[k] * pDoc.m_wordTopic_prob[k][wid];
}
stnLogLikelihood += wordLikelihood;
}
likelihoodMap.put(cDoc.getName(), stnLogLikelihood);
}
return likelihoodMap;
}
use of structures._Word in project IR_Base by Linda-sunshine.
the class DCMCorrLDA_test method rankChild4StnByLikelihood.
protected HashMap<String, Double> rankChild4StnByLikelihood(_Stn stnObj, _ParentDoc4DCM pDoc) {
HashMap<String, Double> likelihoodMap = new HashMap<String, Double>();
for (_ChildDoc cDoc : pDoc.m_childDocs) {
double stnLogLikelihood = 0;
for (_Word w : stnObj.getWords()) {
double wordLikelihood = 0;
int wid = w.getIndex();
for (int k = 0; k < number_of_topics; k++) {
wordLikelihood += childTopicInDocProb(k, cDoc, pDoc) * childWordByTopicProb(k, wid, pDoc);
}
stnLogLikelihood += wordLikelihood;
}
likelihoodMap.put(cDoc.getName(), stnLogLikelihood);
}
return likelihoodMap;
}
Aggregations