diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-12 13:56:42 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-12 13:56:42 +0200 |
commit | 244971287003d079e46193b8a209c28955f90134 (patch) | |
tree | 8beaae6b12b913acb213fc7f2415fd63886192f9 /word-aligner/fast_align.cc | |
parent | 5250fd67a4b8f242068cff87f0a6a4211f8b0fcf (diff) | |
parent | b66e838ed52decc0be1eb5817b2a77c3840db2c5 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'word-aligner/fast_align.cc')
-rw-r--r-- | word-aligner/fast_align.cc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/word-aligner/fast_align.cc b/word-aligner/fast_align.cc index f54233eb..73b72399 100644 --- a/word-aligner/fast_align.cc +++ b/word-aligner/fast_align.cc @@ -190,6 +190,7 @@ int main(int argc, char** argv) { cout << (max_index - 1) << '-' << j; } } + if (s2t_viterbi.size() <= static_cast<unsigned>(max_i)) s2t_viterbi.resize(max_i + 1); s2t_viterbi[max_i][f_j] = 1.0; } } else { @@ -308,17 +309,17 @@ int main(int argc, char** argv) { if (output_parameters) { WriteFile params_out(conf["output_parameters"].as<string>()); - for (TTable::Word2Word2Double::iterator ei = s2t.ttable.begin(); ei != s2t.ttable.end(); ++ei) { - const TTable::Word2Double& cpd = ei->second; - const TTable::Word2Double& vit = s2t_viterbi[ei->first]; - const string& esym = TD::Convert(ei->first); + for (unsigned eind = 1; eind < s2t.ttable.size(); ++eind) { + const auto& cpd = s2t.ttable[eind]; + const TTable::Word2Double& vit = s2t_viterbi[eind]; + const string& esym = TD::Convert(eind); double max_p = -1; - for (TTable::Word2Double::const_iterator fi = cpd.begin(); fi != cpd.end(); ++fi) - if (fi->second > max_p) max_p = fi->second; + for (auto& fi : cpd) + if (fi.second > max_p) max_p = fi.second; const double threshold = max_p * BEAM_THRESHOLD; - for (TTable::Word2Double::const_iterator fi = cpd.begin(); fi != cpd.end(); ++fi) { - if (fi->second > threshold || (vit.find(fi->first) != vit.end())) { - *params_out << esym << ' ' << TD::Convert(fi->first) << ' ' << log(fi->second) << endl; + for (auto& fi : cpd) { + if (fi.second > threshold || (vit.find(fi.first) != vit.end())) { + *params_out << esym << ' ' << TD::Convert(fi.first) << ' ' << log(fi.second) << endl; } } } |