summaryrefslogtreecommitdiff
path: root/phrasinator/gibbs_train_plm.notables.cc
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-05-31 13:57:24 +0200
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-05-31 13:57:24 +0200
commit6f6601111710aa67eee5169e5b7d89102cc33bb8 (patch)
tree0872544abd6bc76162f3f80eb3920999afbf2c34 /phrasinator/gibbs_train_plm.notables.cc
parent8cee8b565a9c56a7732365e9563f52ff3c4ff7fd (diff)
parent090a64e73f94a6a35e5364a9d416dcf75c0a2938 (diff)
Merge remote-tracking branch 'upstream/master'
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")) {