code cleanup

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@579 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
phkoehn 2006-08-08 21:35:13 +00:00
parent 099ed1b113
commit b403c8c784
2 changed files with 8 additions and 3 deletions

View File

@ -99,18 +99,20 @@ bool TranslationOption::Overlap(const Hypothesis &hypothesis) const
return bitmap.Overlap(GetSourceWordsRange());
}
void TranslationOption::CalcScore(const LMList &allLM, float weightWordPenalty)
void TranslationOption::CalcScore()
{
// LM scores
float m_ngramScore = 0;
float retFullScore = 0;
const LMList &allLM = StaticData::Instance()->GetAllLM();
allLM.CalcScore(GetTargetPhrase(), retFullScore, m_ngramScore, &m_scoreBreakdown);
// future score
m_futureScore = retFullScore - m_ngramScore;
size_t phraseSize = GetTargetPhrase().GetSize();
m_futureScore += m_scoreBreakdown.InnerProduct(StaticData::Instance()->GetAllWeights()) - phraseSize * weightWordPenalty;
m_futureScore += m_scoreBreakdown.InnerProduct(StaticData::Instance()->GetAllWeights()) - phraseSize * StaticData::Instance()->GetWeightWordPenalty();
}
TO_STRING_BODY(TranslationOption);

View File

@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "Util.h"
#include "TypeDef.h"
#include "ScoreComponentCollection.h"
#include "StaticData.h"
class PhraseDictionaryBase;
class GenerationDictionary;
@ -60,6 +61,7 @@ protected:
const WordsRange m_sourceWordsRange; /*< word position in the input that are covered by this translation option */
float m_totalScore; /*< weighted translation costs of this translation option */
float m_futureScore; /*< estimate of total cost when using this translation option, includes language model probabilities */
float m_partialScore; /*< estimate of the partial cost of a preliminary translation option */
//! in TranslationOption, m_scoreBreakdown is not complete. It cannot,
//! for example, know the full n-gram score since the length of the
@ -141,7 +143,6 @@ public:
{
return m_targetPhrase.GetSize() == 0;
}
void CalcScore(const LMList &allLM, float weightWordPenalty);
/** returns detailed component scores */
inline const ScoreComponentCollection2 &GetScoreBreakdown() const
@ -149,6 +150,8 @@ public:
return m_scoreBreakdown;
}
void CalcScore();
TO_STRING;
};