summaryrefslogtreecommitdiff
path: root/phrasinator/gibbs_train_plm.notables.cc
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-05-27 15:34:44 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-05-27 15:34:44 -0400
commit71c4918f05a4b380dfaebfabcc1847c1c6d497dd (patch)
treecd2a0c9c9175ddf8100b1c64d689e540f50eeae9 /phrasinator/gibbs_train_plm.notables.cc
parentab38dc57a6a64aa7ef60a845a4176e18e1ac7f27 (diff)
clean up
Diffstat (limited to 'phrasinator/gibbs_train_plm.notables.cc')
-rw-r--r--phrasinator/gibbs_train_plm.notables.cc24
1 files changed, 12 insertions, 12 deletions
diff --git a/phrasinator/gibbs_train_plm.notables.cc b/phrasinator/gibbs_train_plm.notables.cc
index 9dca9e8d..4526eaa6 100644
--- a/phrasinator/gibbs_train_plm.notables.cc
+++ b/phrasinator/gibbs_train_plm.notables.cc
@@ -18,7 +18,7 @@ Dict d; // global dictionary
string Join(char joiner, const vector<int>& phrase) {
ostringstream os;
- for (int i = 0; i < phrase.size(); ++i) {
+ for (unsigned i = 0; i < phrase.size(); ++i) {
if (i > 0) os << joiner;
os << d.Convert(phrase[i]);
}
@@ -29,13 +29,13 @@ template <typename BType>
void WriteSeg(const vector<int>& line, const vector<BType>& label, const Dict& d) {
assert(line.size() == label.size());
assert(label.back());
- int prev = 0;
- int cur = 0;
+ unsigned prev = 0;
+ unsigned cur = 0;
while (cur < line.size()) {
if (label[cur]) {
if (prev) cout << ' ';
cout << "{{";
- for (int i = prev; i <= cur; ++i)
+ for (unsigned i = prev; i <= cur; ++i)
cout << (i == prev ? "" : " ") << d.Convert(line[i]);
cout << "}}:" << label[cur];
prev = cur + 1;
@@ -46,7 +46,7 @@ void WriteSeg(const vector<int>& line, const vector<BType>& label, const Dict& d
}
ostream& operator<<(ostream& os, const vector<int>& phrase) {
- for (int i = 0; i < phrase.size(); ++i)
+ for (unsigned i = 0; i < phrase.size(); ++i)
os << (i == 0 ? "" : " ") << d.Convert(phrase[i]);
return os;
}
@@ -57,7 +57,7 @@ struct UnigramLM {
assert(in);
}
- double logprob(int word) const {
+ double logprob(unsigned word) const {
assert(word < freqs_.size());
return freqs_[word];
}
@@ -111,7 +111,7 @@ void ReadCorpus(const string& filename, vector<vector<int> >* c, set<int>* vocab
c->push_back(vector<int>());
vector<int>& v = c->back();
d.ConvertWhitespaceDelimitedLine(line, &v);
- for (int i = 0; i < v.size(); ++i) vocab->insert(v[i]);
+ for (unsigned i = 0; i < v.size(); ++i) vocab->insert(v[i]);
}
if (in != &cin) delete in;
}
@@ -175,7 +175,7 @@ struct UniphraseLM {
cerr << "Initializing...\n";
z_.resize(corpus_.size());
int tc = 0;
- for (int i = 0; i < corpus_.size(); ++i) {
+ for (unsigned i = 0; i < corpus_.size(); ++i) {
const vector<int>& line = corpus_[i];
const int ls = line.size();
const int last_pos = ls - 1;
@@ -201,7 +201,7 @@ struct UniphraseLM {
cerr << "Initial LLH: " << llh() << endl;
cerr << "Sampling...\n";
cerr << gen_ << endl;
- for (int s = 1; s < samples; ++s) {
+ for (unsigned s = 1; s < samples; ++s) {
cerr << '.';
if (s % 10 == 0) {
cerr << " [" << s;
@@ -211,7 +211,7 @@ struct UniphraseLM {
//for (int j = 0; j < z.size(); ++j) z[j] = z_[0][j];
//SegCorpus::Write(corpus_[0], z, d);
}
- for (int i = 0; i < corpus_.size(); ++i) {
+ for (unsigned i = 0; i < corpus_.size(); ++i) {
const vector<int>& line = corpus_[i];
const int ls = line.size();
const int last_pos = ls - 1;
@@ -276,7 +276,7 @@ struct UniphraseLM {
void ResampleHyperparameters(MT19937* rng) {
phrases_.resample_hyperparameters(rng);
gen_.resample_hyperparameters(rng);
- cerr << " " << phrases_.concentration();
+ cerr << " " << phrases_.alpha();
}
CCRP_NoTable<vector<int> > phrases_;
@@ -310,7 +310,7 @@ int main(int argc, char** argv) {
ulm.Sample(conf["samples"].as<unsigned>(), conf.count("no_hyperparameter_inference") == 0, &rng);
cerr << "OOV unigram prob: " << ulm.OOVUnigramLogProb() << endl;
- for (int i = 0; i < corpus.size(); ++i)
+ for (unsigned i = 0; i < corpus.size(); ++i)
WriteSeg(corpus[i], ulm.z_[i], d);
if (conf.count("write_cdec_grammar")) {