From afb1bcd5ba7364ec03f3d1067b1669581d965225 Mon Sep 17 00:00:00 2001 From: redpony Date: Tue, 22 Jun 2010 22:46:51 +0000 Subject: clean up git-svn-id: https://ws10smt.googlecode.com/svn/trunk@7 ec762483-ff6d-05da-a07a-a48fb63a330f --- gi/clda/src/clda.cc | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'gi') diff --git a/gi/clda/src/clda.cc b/gi/clda/src/clda.cc index 49702df3..4dd4789c 100644 --- a/gi/clda/src/clda.cc +++ b/gi/clda/src/clda.cc @@ -16,18 +16,31 @@ void ShowTopWords(const map& counts) { multimap ms; for (map::const_iterator it = counts.begin(); it != counts.end(); ++it) ms.insert(make_pair(it->second, it->first)); + int cc = 0; + for (multimap::reverse_iterator it = ms.rbegin(); it != ms.rend(); ++it) { + cerr << it->first << ':' << TD::Convert(it->second) << " "; + ++cc; + if (cc==12) break; + } + cerr << endl; } int main(int argc, char** argv) { - if (argc != 2) { - cerr << "Usage: " << argv[0] << " num-classes\n"; + if (argc != 3) { + cerr << "Usage: " << argv[0] << " num-classes num-samples\n"; return 1; } const int num_classes = atoi(argv[1]); + const int num_iterations = atoi(argv[2]); + const int burnin_size = num_iterations * 0.666; if (num_classes < 2) { cerr << "Must request more than 1 class\n"; return 1; } + if (num_iterations < 5) { + cerr << "Must request more than 5 iterations\n"; + return 1; + } cerr << "CLASSES: " << num_classes << endl; char* buf = new char[800000]; vector > wji; // w[j][i] - observed word i of doc j @@ -63,8 +76,6 @@ int main(int argc, char** argv) { } cerr << "SAMPLING\n"; vector > t2w(num_classes); - const int num_iterations = 1000; - const int burnin_size = 800; bool needline = false; Timer timer; SampleSet ss; @@ -114,6 +125,7 @@ int main(int argc, char** argv) { } } if (needline) cerr << endl; +#if 0 for (int j = 0; j < zji.size(); ++j) { const size_t num_words = wji[j].size(); vector& zj = zji[j]; @@ -124,17 +136,11 @@ int main(int argc, char** argv) { } cout << endl; } +#endif for (int i = 0; i < num_classes; ++i) { + cerr << "---------------------------------\n"; ShowTopWords(t2w[i]); } - for (map::iterator it = t2w[0].begin(); it != t2w[0].end(); ++it) - cerr << TD::Convert(it->first) << " " << it->second << endl; - cerr << "---------------------------------\n"; - for (map::iterator it = t2w[1].begin(); it != t2w[1].end(); ++it) - cerr << TD::Convert(it->first) << " " << it->second << endl; - cerr << "---------------------------------\n"; - for (map::iterator it = t2w[2].begin(); it != t2w[2].end(); ++it) - cerr << TD::Convert(it->first) << " " << it->second << endl; return 0; } -- cgit v1.2.3