use of structures._ChildDoc in project IR_Base by Linda-sunshine.
the class ACCTM method parentChildInfluenceProb.
protected double parentChildInfluenceProb(int tid, _ParentDoc pDoc) {
double term = 1.0;
if (tid == 0)
return term;
double topicSum = Utils.sumOfArray(pDoc.m_sstat);
for (_ChildDoc cDoc : pDoc.m_childDocs) {
double muDp = cDoc.getMu() / topicSum;
term *= gammaFuncRatio((int) cDoc.m_sstat[tid], muDp, d_alpha + pDoc.m_sstat[tid] * muDp) / gammaFuncRatio((int) cDoc.m_sstat[0], muDp, d_alpha + pDoc.m_sstat[0] * muDp);
}
return term;
}
use of structures._ChildDoc in project IR_Base by Linda-sunshine.
the class ACCTM method initialize_probability.
protected void initialize_probability(Collection<_Doc> collection) {
createSpace();
for (int i = 0; i < number_of_topics; i++) Arrays.fill(word_topic_sstat[i], d_beta);
// avoid adding such prior later on
Arrays.fill(m_sstat, d_beta * vocabulary_size);
for (_Doc d : collection) {
if (d instanceof _ParentDoc) {
d.setTopics4Gibbs(number_of_topics, 0);
for (_Stn stnObj : d.getSentences()) stnObj.setTopicsVct(number_of_topics);
} else if (d instanceof _ChildDoc) {
((_ChildDoc) d).setTopics4Gibbs_LDA(number_of_topics, 0);
computeMu4Doc((_ChildDoc) d);
}
for (_Word w : d.getWords()) {
word_topic_sstat[w.getTopic()][w.getIndex()]++;
m_sstat[w.getTopic()]++;
}
}
imposePrior();
m_statisticsNormalized = false;
}
use of structures._ChildDoc in project IR_Base by Linda-sunshine.
the class ACCTM_C method initialize_probability.
protected void initialize_probability(Collection<_Doc> collection) {
createSpace();
for (int i = 0; i < number_of_topics; i++) Arrays.fill(word_topic_sstat[i], d_beta);
Arrays.fill(m_sstat, d_beta * vocabulary_size);
for (_Doc d : collection) {
if (d instanceof _ParentDoc) {
d.setTopics4Gibbs(number_of_topics, 0);
for (_Stn stnObj : d.getSentences()) stnObj.setTopicsVct(number_of_topics);
} else if (d instanceof _ChildDoc4BaseWithPhi) {
((_ChildDoc4BaseWithPhi) d).createXSpace(number_of_topics, m_gamma.length, vocabulary_size, d_beta);
((_ChildDoc4BaseWithPhi) d).setTopics4Gibbs(number_of_topics, 0);
computeMu4Doc((_ChildDoc) d);
}
if (d instanceof _ParentDoc) {
for (_Word w : d.getWords()) {
word_topic_sstat[w.getTopic()][w.getIndex()]++;
m_sstat[w.getTopic()]++;
}
} else if (d instanceof _ChildDoc4BaseWithPhi) {
for (_Word w : d.getWords()) {
int xid = w.getX();
int tid = w.getTopic();
int wid = w.getIndex();
// update global
if (xid == 0) {
word_topic_sstat[tid][wid]++;
m_sstat[tid]++;
}
}
}
}
imposePrior();
m_statisticsNormalized = false;
}
use of structures._ChildDoc in project IR_Base by Linda-sunshine.
the class ACCTM_CZ method childTopicInDocProb.
@Override
protected double childTopicInDocProb(int tid, _ChildDoc d) {
_ParentDoc pDoc = d.m_parentDoc;
double pDocTopicSum = Utils.sumOfArray(pDoc.m_sstat);
return (d.m_parentDoc.m_sstat[tid] + m_smoothingParam) / (pDocTopicSum + m_smoothingParam * number_of_topics);
}
use of structures._ChildDoc in project IR_Base by Linda-sunshine.
the class ACCTM_CZLR method xProb4Word.
public double xProb4Word(int xid, _Word w, _ChildDoc cDoc) {
double result = 0;
_ParentDoc pDoc = cDoc.m_parentDoc;
double temp1 = pDoc.m_featureWeight.length;
double temp2 = w.getFeatures().length;
result = Utils.dotProduct(pDoc.m_featureWeight, w.getFeatures());
if (xid == 1)
result = 1 / (1 + Math.exp(-result));
else
result = 1 / (1 + Math.exp(result));
return result;
}
Aggregations