diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2013-05-29 21:16:15 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2013-05-29 21:16:15 +0400 |
commit | 6249432407af8730c10bccc7894c0725fcaf5e47 (patch) | |
tree | 3ac1f094b9fdc199b04bc5ef209ce00e3596e37d /moses/ChartHypothesis.cpp | |
parent | 59bd7deb4b6b9c4f7b3b7dbb055783528fbc31ca (diff) |
beautify
Diffstat (limited to 'moses/ChartHypothesis.cpp')
-rw-r--r-- | moses/ChartHypothesis.cpp | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/moses/ChartHypothesis.cpp b/moses/ChartHypothesis.cpp index c7c1047f1..ce5a318ac 100644 --- a/moses/ChartHypothesis.cpp +++ b/moses/ChartHypothesis.cpp @@ -39,7 +39,7 @@ namespace Moses ObjectPool<ChartHypothesis> ChartHypothesis::s_objectPool("ChartHypothesis", 300000); #endif -/** Create a hypothesis from a rule +/** Create a hypothesis from a rule * \param transOpt wrapper around the rule * \param item @todo dunno * \param manager reference back to manager @@ -59,15 +59,14 @@ ChartHypothesis::ChartHypothesis(const ChartTranslationOptions &transOpt, const std::vector<HypothesisDimension> &childEntries = item.GetHypothesisDimensions(); m_prevHypos.reserve(childEntries.size()); std::vector<HypothesisDimension>::const_iterator iter; - for (iter = childEntries.begin(); iter != childEntries.end(); ++iter) - { + for (iter = childEntries.begin(); iter != childEntries.end(); ++iter) { m_prevHypos.push_back(iter->GetHypothesis()); } } ChartHypothesis::~ChartHypothesis() { - // delete feature function states + // delete feature function states for (unsigned i = 0; i < m_ffStates.size(); ++i) { delete m_ffStates[i]; } @@ -98,8 +97,7 @@ void ChartHypothesis::CreateOutputPhrase(Phrase &outPhrase) const size_t nonTermInd = GetCurrTargetPhrase().GetAlignNonTerm().GetNonTermIndexMap()[pos]; const ChartHypothesis *prevHypo = m_prevHypos[nonTermInd]; prevHypo->CreateOutputPhrase(outPhrase); - } - else { + } else { outPhrase.AddWord(word); } } @@ -124,17 +122,16 @@ Phrase ChartHypothesis::GetOutputPhrase() const */ int ChartHypothesis::RecombineCompare(const ChartHypothesis &compare) const { - int comp = 0; + int comp = 0; - for (unsigned i = 0; i < m_ffStates.size(); ++i) - { - if (m_ffStates[i] == NULL || compare.m_ffStates[i] == NULL) + for (unsigned i = 0; i < m_ffStates.size(); ++i) { + if (m_ffStates[i] == NULL || compare.m_ffStates[i] == NULL) comp = m_ffStates[i] - compare.m_ffStates[i]; - else + else comp = m_ffStates[i]->Compare(*compare.m_ffStates[i]); - if (comp != 0) - return comp; + if (comp != 0) + return comp; } return 0; @@ -161,16 +158,16 @@ void ChartHypothesis::CalcScore() //Add pre-computed features m_manager.InsertPreCalculatedScores(GetCurrTargetPhrase(), &m_scoreBreakdown); - // compute values of stateless feature functions that were not + // compute values of stateless feature functions that were not // cached in the translation option-- there is no principled distinction const std::vector<const StatelessFeatureFunction*>& sfs = - StatelessFeatureFunction::GetStatelessFeatureFunctions(); + StatelessFeatureFunction::GetStatelessFeatureFunctions(); for (unsigned i = 0; i < sfs.size(); ++i) { sfs[i]->EvaluateChart(ChartBasedFeatureContext(this),&m_scoreBreakdown); } const std::vector<const StatefulFeatureFunction*>& ffs = - StatefulFeatureFunction::GetStatefulFeatureFunctions(); + StatefulFeatureFunction::GetStatefulFeatureFunctions(); for (unsigned i = 0; i < ffs.size(); ++i) m_ffStates[i] = ffs[i]->EvaluateChart(*this,i,&m_scoreBreakdown); @@ -262,13 +259,12 @@ std::ostream& operator<<(std::ostream& out, const ChartHypothesis& hypo) { out << hypo.GetId(); - - // recombination - if (hypo.GetWinningHypothesis() != NULL && - hypo.GetWinningHypothesis() != &hypo) - { - out << "->" << hypo.GetWinningHypothesis()->GetId(); - } + + // recombination + if (hypo.GetWinningHypothesis() != NULL && + hypo.GetWinningHypothesis() != &hypo) { + out << "->" << hypo.GetWinningHypothesis()->GetId(); + } if (StaticData::Instance().GetIncludeLHSInSearchGraph()) { out << " " << hypo.GetTargetLHS() << "=>"; |