Search in sources :

Example 26 with structures._ChildDoc

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

Example 27 with structures._ChildDoc

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;
}
Also used : structures._Stn(structures._Stn) structures._ChildDoc(structures._ChildDoc) structures._Doc(structures._Doc) structures._ParentDoc(structures._ParentDoc) structures._Word(structures._Word)

Example 28 with structures._ChildDoc

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;
}
Also used : structures._ChildDoc4BaseWithPhi(structures._ChildDoc4BaseWithPhi) structures._Stn(structures._Stn) structures._ChildDoc(structures._ChildDoc) structures._Doc(structures._Doc) structures._ParentDoc(structures._ParentDoc) structures._Word(structures._Word)

Example 29 with structures._ChildDoc

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

Example 30 with structures._ChildDoc

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

Aggregations

structures._ChildDoc (structures._ChildDoc)77 structures._ParentDoc (structures._ParentDoc)47 structures._Doc (structures._Doc)35 structures._Stn (structures._Stn)25 structures._Word (structures._Word)22 File (java.io.File)18 structures._ParentDoc4DCM (structures._ParentDoc4DCM)16 structures._SparseFeature (structures._SparseFeature)16 HashMap (java.util.HashMap)14 PrintWriter (java.io.PrintWriter)12 FileNotFoundException (java.io.FileNotFoundException)11 structures._ChildDoc4BaseWithPhi (structures._ChildDoc4BaseWithPhi)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)2 Feature (Classifier.supervised.liblinear.Feature)1 FeatureNode (Classifier.supervised.liblinear.FeatureNode)1 Model (Classifier.supervised.liblinear.Model)1 Parameter (Classifier.supervised.liblinear.Parameter)1 Problem (Classifier.supervised.liblinear.Problem)1 SolverType (Classifier.supervised.liblinear.SolverType)1