mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Hypothesis: get rid of calls into Manager from constructor
This commit is contained in:
parent
b1ea3d624b
commit
73ab44c126
@ -224,7 +224,7 @@ Hypothesis *BackwardsEdge::CreateHypothesis(const Hypothesis &hypothesis, const
|
||||
hypothesis.GetManager().GetSentenceStats().StartTimeBuildHyp();
|
||||
}
|
||||
const Bitmap &bitmap = m_parent.GetWordsBitmap();
|
||||
Hypothesis *newHypo = new Hypothesis(hypothesis, transOpt, bitmap);
|
||||
Hypothesis *newHypo = new Hypothesis(hypothesis, transOpt, bitmap, hypothesis.GetManager().GetNextHypoId());
|
||||
IFVERBOSE(2) {
|
||||
hypothesis.GetManager().GetSentenceStats().StopTimeBuildHyp();
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ using namespace std;
|
||||
namespace Moses
|
||||
{
|
||||
Hypothesis::
|
||||
Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt, const Bitmap &bitmap)
|
||||
Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt, const Bitmap &bitmap, int id)
|
||||
: m_prevHypo(NULL)
|
||||
, m_sourceCompleted(bitmap)
|
||||
, m_sourceInput(source)
|
||||
@ -59,7 +59,7 @@ Hypothesis(Manager& manager, InputType const& source, const TranslationOption &i
|
||||
, m_arcList(NULL)
|
||||
, m_transOpt(initialTransOpt)
|
||||
, m_manager(manager)
|
||||
, m_id(m_manager.GetNextHypoId())
|
||||
, m_id(id)
|
||||
{
|
||||
// used for initial seeding of trans process
|
||||
// initialize scores
|
||||
@ -68,14 +68,13 @@ Hypothesis(Manager& manager, InputType const& source, const TranslationOption &i
|
||||
const vector<const StatefulFeatureFunction*>& ffs = StatefulFeatureFunction::GetStatefulFeatureFunctions();
|
||||
for (unsigned i = 0; i < ffs.size(); ++i)
|
||||
m_ffStates[i] = ffs[i]->EmptyHypothesisState(source);
|
||||
m_manager.GetSentenceStats().AddCreated();
|
||||
}
|
||||
|
||||
/***
|
||||
* continue prevHypo by appending the phrases in transOpt
|
||||
*/
|
||||
Hypothesis::
|
||||
Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt, const Bitmap &bitmap)
|
||||
Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt, const Bitmap &bitmap, int id)
|
||||
: m_prevHypo(&prevHypo)
|
||||
, m_sourceCompleted(bitmap)
|
||||
, m_sourceInput(prevHypo.m_sourceInput)
|
||||
@ -90,11 +89,10 @@ Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt, const
|
||||
, m_arcList(NULL)
|
||||
, m_transOpt(transOpt)
|
||||
, m_manager(prevHypo.GetManager())
|
||||
, m_id(m_manager.GetNextHypoId())
|
||||
, m_id(id)
|
||||
{
|
||||
m_currScoreBreakdown.PlusEquals(transOpt.GetScoreBreakdown());
|
||||
m_wordDeleted = transOpt.IsDeletionOption();
|
||||
m_manager.GetSentenceStats().AddCreated();
|
||||
}
|
||||
|
||||
Hypothesis::
|
||||
|
@ -86,9 +86,9 @@ protected:
|
||||
|
||||
public:
|
||||
/*! used by initial seeding of the translation process */
|
||||
Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt, const Bitmap &bitmap);
|
||||
Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt, const Bitmap &bitmap, int id);
|
||||
/*! used when creating a new hypothesis using a translation option (phrase translation) */
|
||||
Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt, const Bitmap &bitmap);
|
||||
Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt, const Bitmap &bitmap, int id);
|
||||
~Hypothesis();
|
||||
|
||||
void PrintHypothesis() const;
|
||||
|
@ -1480,6 +1480,7 @@ const Hypothesis *Manager::GetBestHypothesis() const
|
||||
|
||||
int Manager::GetNextHypoId()
|
||||
{
|
||||
GetSentenceStats().AddCreated(); // count created hypotheses
|
||||
return m_hypoId++;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ MockHypothesisGuard
|
||||
|
||||
const Bitmap &initBitmap = bitmaps.GetInitialBitmap();
|
||||
m_hypothesis = new Hypothesis(*m_manager, *m_sentence, m_initialTransOpt,
|
||||
initBitmap);
|
||||
initBitmap, m_manager->GetNextHypoId());
|
||||
|
||||
//create the chain
|
||||
vector<Alignment>::const_iterator ai = alignments.begin();
|
||||
@ -67,7 +67,7 @@ MockHypothesisGuard
|
||||
m_targetPhrases.back().CreateFromString(Input, factors, *ti, NULL);
|
||||
m_toptions.push_back(new TranslationOption
|
||||
(range,m_targetPhrases.back()));
|
||||
m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back(), newBitmap);
|
||||
m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back(), newBitmap, m_manager->GetNextHypoId());
|
||||
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ void SearchCubePruning::Decode()
|
||||
{
|
||||
// initial seed hypothesis: nothing translated, no words produced
|
||||
const Bitmap &initBitmap = m_bitmaps.GetInitialBitmap();
|
||||
Hypothesis *hypo = new Hypothesis(m_manager, m_source, m_initialTransOpt, initBitmap);
|
||||
Hypothesis *hypo = new Hypothesis(m_manager, m_source, m_initialTransOpt, initBitmap, m_manager.GetNextHypoId());
|
||||
|
||||
HypothesisStackCubePruning &firstStack
|
||||
= *static_cast<HypothesisStackCubePruning*>(m_hypoStackColl.front());
|
||||
|
@ -86,7 +86,7 @@ void SearchNormal::Decode()
|
||||
|
||||
// initial seed hypothesis: nothing translated, no words produced
|
||||
const Bitmap &initBitmap = m_bitmaps.GetInitialBitmap();
|
||||
Hypothesis *hypo = new Hypothesis(m_manager, m_source, m_initialTransOpt, initBitmap);
|
||||
Hypothesis *hypo = new Hypothesis(m_manager, m_source, m_initialTransOpt, initBitmap, m_manager.GetNextHypoId());
|
||||
|
||||
m_hypoStackColl[0]->AddPrune(hypo);
|
||||
|
||||
@ -302,7 +302,7 @@ void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis,
|
||||
IFVERBOSE(2) {
|
||||
stats.StartTimeBuildHyp();
|
||||
}
|
||||
newHypo = new Hypothesis(hypothesis, transOpt, bitmap);
|
||||
newHypo = new Hypothesis(hypothesis, transOpt, bitmap, m_manager.GetNextHypoId());
|
||||
IFVERBOSE(2) {
|
||||
stats.StopTimeBuildHyp();
|
||||
}
|
||||
@ -336,7 +336,7 @@ void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis,
|
||||
IFVERBOSE(2) {
|
||||
stats.StartTimeBuildHyp();
|
||||
}
|
||||
newHypo = new Hypothesis(hypothesis, transOpt, bitmap);
|
||||
newHypo = new Hypothesis(hypothesis, transOpt, bitmap, m_manager.GetNextHypoId());
|
||||
if (newHypo==NULL) return;
|
||||
IFVERBOSE(2) {
|
||||
stats.StopTimeBuildHyp();
|
||||
|
Loading…
Reference in New Issue
Block a user