diff options
author | John Langford <jl@hunch.net> | 2010-04-24 01:17:22 +0400 |
---|---|---|
committer | John Langford <jl@hunch.net> | 2010-04-24 01:17:22 +0400 |
commit | dcbdf822ed9ce8af1f3acadbe0cf208c064cc5b0 (patch) | |
tree | 8b49ffdbd21965e9988a893a7bae2676b5b81953 /parse_regressor.cc | |
parent | 147706f3e623f52d32b25640e59bc69fca9a8643 (diff) |
ngrams debugged
Diffstat (limited to 'parse_regressor.cc')
-rw-r--r-- | parse_regressor.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/parse_regressor.cc b/parse_regressor.cc index fb9e0cf4..660a2b69 100644 --- a/parse_regressor.cc +++ b/parse_regressor.cc @@ -109,7 +109,6 @@ void parse_regressor_args(po::variables_map& vm, regressor& r, string& final_reg { global.pairs = local_pairs; initialize_regressor(r); - initialized = true; } else if (local_pairs != global.pairs) @@ -123,6 +122,22 @@ void parse_regressor_args(po::variables_map& vm, regressor& r, string& final_reg cout << endl; exit (1); } + size_t local_ngram; + regressor.read((char*)&local_ngram, sizeof(local_ngram)); + size_t local_skips; + regressor.read((char*)&local_skips, sizeof(local_skips)); + if (!initialized) + { + global.ngram = local_ngram; + global.skips = local_skips; + initialized = true; + } + else + if (global.ngram != local_ngram || global.skips != local_skips) + { + cout << "can't combine regressors with different ngram features!" << endl; + exit(1); + } while (regressor.good()) { uint32_t hash; @@ -172,7 +187,9 @@ void dump_regressor(ofstream &o, regressor &r) o.write((char *)&len, sizeof(len)); for (vector<string>::iterator i = global.pairs.begin(); i != global.pairs.end();i++) o << (*i)[0] << (*i)[1]; - + o.write((char*)&global.ngram, sizeof(global.ngram)); + o.write((char*)&global.skips, sizeof(global.skips)); + uint32_t length = 1 << global.num_bits; size_t num_threads = global.num_threads(); for(uint32_t i = 0; i < length; i++) |