From ef105a1a9b6a9ae731e243c80c760215b765636d Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Thu, 1 Dec 2016 14:41:30 +0000 Subject: [PATCH] reset beam variables when clearing ministack. They are reused --- contrib/moses2/HypothesisColl.cpp | 21 +++++++++++++++---- .../CubePruningMiniStack/Search.cpp | 3 +-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/contrib/moses2/HypothesisColl.cpp b/contrib/moses2/HypothesisColl.cpp index a47c7a5de..a42c755aa 100644 --- a/contrib/moses2/HypothesisColl.cpp +++ b/contrib/moses2/HypothesisColl.cpp @@ -18,9 +18,9 @@ using namespace std; namespace Moses2 { -HypothesisColl::HypothesisColl(const ManagerBase &mgr) : - m_coll(MemPoolAllocator(mgr.GetPool())), m_sortedHypos( - NULL) +HypothesisColl::HypothesisColl(const ManagerBase &mgr) +:m_coll(MemPoolAllocator(mgr.GetPool())) +,m_sortedHypos(NULL) { m_bestScore = -std::numeric_limits::infinity(); m_worstScore = -std::numeric_limits::infinity(); @@ -53,17 +53,28 @@ void HypothesisColl::Add( ArcLists &arcLists) { SCORE futureScore = hypo->GetFutureScore(); + /* + cerr << "scores:" + << futureScore << " " + << m_bestScore << " " + << m_worstScore << " " + << GetSize() << " " + << endl; + */ if (futureScore < m_worstScore) { // beam threshold + //cerr << "Discard:" << hypo->Debug(system) << endl; hypoRecycle.Recycle(hypo); return; } + //cerr << "OK:" << hypo->Debug(system) << endl; if (futureScore > m_bestScore) { m_bestScore = hypo->GetFutureScore(); // this may also affect the worst score SCORE beamWidth = system.options.search.beam_width; + //cerr << "beamWidth=" << beamWidth << endl; if ( m_bestScore + beamWidth > m_worstScore ) { m_worstScore = m_bestScore + beamWidth; } @@ -112,7 +123,7 @@ StackAdd HypothesisColl::Add(const HypothesisBase *hypo) } } - assert(false); + //assert(false); } const Hypotheses &HypothesisColl::GetSortedAndPruneHypos( @@ -192,6 +203,8 @@ void HypothesisColl::Clear() { m_sortedHypos = NULL; m_coll.clear(); + m_bestScore = -std::numeric_limits::infinity(); + m_worstScore = -std::numeric_limits::infinity(); } std::string HypothesisColl::Debug(const System &system) const diff --git a/contrib/moses2/PhraseBased/CubePruningMiniStack/Search.cpp b/contrib/moses2/PhraseBased/CubePruningMiniStack/Search.cpp index 8598b3494..d74cb7d99 100644 --- a/contrib/moses2/PhraseBased/CubePruningMiniStack/Search.cpp +++ b/contrib/moses2/PhraseBased/CubePruningMiniStack/Search.cpp @@ -73,10 +73,9 @@ void Search::Decode() //cerr << "stackInd=" << stackInd << endl; m_stack.Clear(); Decode(stackInd); - PostDecode(stackInd); + PostDecode(stackInd); //m_stack.DebugCounts(); - //cerr << m_stacks << endl; } }