mosesdecoder/contrib/other-builds/moses2/SCFG/Stack.cpp

44 lines
780 B
C++
Raw Normal View History

2016-02-29 18:51:17 +03:00
#include "Stacks.h"
2016-04-17 11:47:04 +03:00
#include "Hypothesis.h"
#include "TargetPhraseImpl.h"
#include "Manager.h"
2016-02-29 18:51:17 +03:00
namespace Moses2
{
namespace SCFG
{
2016-04-17 11:47:04 +03:00
Stack::Stack(const Manager &mgr)
:m_mgr(mgr)
{
}
void Stack::Add(SCFG::Hypothesis *hypo, Recycler<HypothesisBase*> &hypoRecycle,
ArcLists &arcLists)
{
const SCFG::TargetPhraseImpl &tp = hypo->GetTargetPhrase();
const SCFG::Word &lhs = tp.lhs;
HypothesisColl &coll = GetMiniStack(lhs);
StackAdd added = coll.Add(hypo);
}
Moses2::HypothesisColl &Stack::GetMiniStack(const SCFG::Word &key)
{
Moses2::HypothesisColl *ret;
Coll::iterator iter;
iter = m_coll.find(key);
if (iter == m_coll.end()) {
ret = new Moses2::HypothesisColl(m_mgr);
m_coll[key] = ret;
}
else {
ret = iter->second;
}
return *ret;
}
2016-02-29 18:51:17 +03:00
}
}