diff options
author | Phil Williams <philip.williams@mac.com> | 2014-04-21 13:19:00 +0400 |
---|---|---|
committer | Phil Williams <philip.williams@mac.com> | 2014-04-21 13:19:00 +0400 |
commit | b308bd56579a6791ccd8d0d326acb0e0b74d1b20 (patch) | |
tree | 5393a4ca2e7f86de37c19712d2a9653fe823aec8 /moses/ChartKBestExtractor.cpp | |
parent | 76a4609cff1b5bc9a5581e83dcddaf21d696682d (diff) |
moses_chart: enable ChartKBestExtractor.
Diffstat (limited to 'moses/ChartKBestExtractor.cpp')
-rw-r--r-- | moses/ChartKBestExtractor.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/moses/ChartKBestExtractor.cpp b/moses/ChartKBestExtractor.cpp index 72a894ba7..3a16198fc 100644 --- a/moses/ChartKBestExtractor.cpp +++ b/moses/ChartKBestExtractor.cpp @@ -200,21 +200,20 @@ void ChartKBestExtractor::LazyKthBest(Vertex &v, std::size_t k, // Add derivations to the k-best list until it contains k or there are none // left to add. while (v.kBestList.size() < k) { - if (!v.kBestList.empty()) { - // Update the priority queue by adding the successors of the last - // derivation (unless they've been seen before). - boost::shared_ptr<Derivation> d(v.kBestList.back()); - LazyNext(v, *d, globalK); - } + assert(!v.kBestList.empty()); + // Update the priority queue by adding the successors of the last + // derivation (unless they've been seen before). + boost::shared_ptr<Derivation> d(v.kBestList.back()); + LazyNext(v, *d, globalK); // Check if there are any derivations left in the queue. if (v.candidates.empty()) { break; } // Get the next best derivation and delete it from the queue. - boost::weak_ptr<Derivation> d = v.candidates.top(); + boost::weak_ptr<Derivation> next = v.candidates.top(); v.candidates.pop(); // Add it to the k-best list. - v.kBestList.push_back(d); + v.kBestList.push_back(next); } } @@ -250,7 +249,7 @@ ChartKBestExtractor::Derivation::Derivation(const UnweightedHyperarc &e) subderivations.reserve(arity); for (std::size_t i = 0; i < arity; ++i) { const Vertex &pred = *edge.tail[i]; - assert(pred.kBestList.size() == 1); + assert(pred.kBestList.size() >= 1); boost::shared_ptr<Derivation> sub(pred.kBestList[0]); subderivations.push_back(sub); } |