Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4fee696

Browse files
author
Jonathan Chang
committed
Get some posteriors in there as well
1 parent 7449a3a commit 4fee696

5 files changed

+31
-1
lines changed

DirichletPosterior.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class MultinomialPosterior {
2+
MatrixBackedTopicCounts topics;
3+
public:
4+
MultinomialPosterior(const int K_) : topics(K_) {
5+
}
6+
7+
virtual double evaluate(const Position& position, const int topic) const {
8+
position.getDocument()
9+
}
10+
};

MatrixBackedTopicCounts.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class MatrixBackedTopicCounts : public TopicCounts {
1111
}
1212

1313
virtual void update(const int topic, const int word, const int count) {
14-
14+
topic_word_counts_(topic, word) += count;
15+
topic_word_counts_(topic) += count;
1516
}
1617
};

MultinomialPosterior.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class MultinomialPosterior {
2+
MatrixBackedTopicCounts topics;
3+
public:
4+
MultinomialPosterior(const int K_) : topics(K_) {
5+
}
6+
7+
virtual double evaluate(const Position& position, const int topic) const {
8+
position.getDocument()
9+
}
10+
};

Posterior.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Posterior {
2+
public:
3+
virtual double evaluate(const Position& position, const int topic) const = 0;
4+
virtual void update(const Position& position, const int topic, const int count) = 0;
5+
};

TopicCounts.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
class TopicCounts {
2+
int K_;
23
public:
4+
TopicCounts(const int K) : K_(K) {
5+
}
6+
37
virtual int getTopicWordCount(const int topic, const int word) const = 0;
48
virtual int getTopicCount(const int topic) const = 0;
59
virtual void update(const int topic, const int word, const int count) = 0;

0 commit comments

Comments
 (0)