minor changes for debuggablility

This commit is contained in:
Hieu Hoang 2013-04-22 13:03:07 +01:00
parent b1da4dbe0e
commit 3bfcdd0077
3 changed files with 18 additions and 12 deletions

View File

@ -261,17 +261,17 @@ void Hypothesis::IncorporateTransOptScores() {
m_currScoreBreakdown.PlusEquals(m_transOpt->GetScoreBreakdown());
}
void Hypothesis::EvaluateWith(StatefulFeatureFunction* sfff,
void Hypothesis::EvaluateWith(const StatefulFeatureFunction &sfff,
int state_idx) {
m_ffStates[state_idx] = sfff->Evaluate(
m_ffStates[state_idx] = sfff.Evaluate(
*this,
m_prevHypo ? m_prevHypo->m_ffStates[state_idx] : NULL,
&m_currScoreBreakdown);
}
void Hypothesis::EvaluateWith(const StatelessFeatureFunction* slff) {
slff->Evaluate(PhraseBasedFeatureContext(this), &m_currScoreBreakdown);
void Hypothesis::EvaluateWith(const StatelessFeatureFunction& slff) {
slff.Evaluate(PhraseBasedFeatureContext(this), &m_currScoreBreakdown);
}
void Hypothesis::CalculateFutureScore(const SquareMatrix& futureScore) {
@ -302,15 +302,17 @@ void Hypothesis::CalcScore(const SquareMatrix &futureScore)
const vector<const StatelessFeatureFunction*>& sfs =
StatelessFeatureFunction::GetStatelessFeatureFunctions();
for (unsigned i = 0; i < sfs.size(); ++i) {
if (!sfs[i]->ComputeValueInTranslationOption()) {
EvaluateWith(sfs[i]);
const StatelessFeatureFunction &ff = *sfs[i];
if (!ff.ComputeValueInTranslationOption()) {
EvaluateWith(ff);
}
}
const vector<const StatefulFeatureFunction*>& ffs =
StatefulFeatureFunction::GetStatefulFeatureFunctions();
for (unsigned i = 0; i < ffs.size(); ++i) {
m_ffStates[i] = ffs[i]->Evaluate(
const StatefulFeatureFunction &ff = *ffs[i];
m_ffStates[i] = ff.Evaluate(
*this,
m_prevHypo ? m_prevHypo->m_ffStates[i] : NULL,
&m_currScoreBreakdown);

View File

@ -266,8 +266,8 @@ public:
// Added by oliver.wilson@ed.ac.uk for async lm stuff.
void IncorporateTransOptScores();
void EvaluateWith(StatefulFeatureFunction* sfff, int state_idx);
void EvaluateWith(const StatelessFeatureFunction* slff);
void EvaluateWith(const StatefulFeatureFunction &sfff, int state_idx);
void EvaluateWith(const StatelessFeatureFunction &slff);
void CalculateFutureScore(const SquareMatrix& futureScore);
void CalculateFinalScore();

View File

@ -1,6 +1,7 @@
#include "SearchNormalBatch.h"
#include "LM/Base.h"
#include "Manager.h"
#include "Hypothesis.h"
//#include <google/profiler.h>
@ -163,13 +164,15 @@ void SearchNormalBatch::EvalAndMergePartialHypos() {
for (sfff_iter = m_stateful_ffs.begin();
sfff_iter != m_stateful_ffs.end();
++sfff_iter) {
hypo->EvaluateWith((*sfff_iter).second, (*sfff_iter).first);
const StatefulFeatureFunction &ff = *(sfff_iter->second);
int state_idx = sfff_iter->first;
hypo->EvaluateWith(ff, state_idx);
}
std::vector<const StatelessFeatureFunction*>::iterator slff_iter;
for (slff_iter = m_stateless_ffs.begin();
slff_iter != m_stateless_ffs.end();
++slff_iter) {
hypo->EvaluateWith(*slff_iter);
hypo->EvaluateWith(**slff_iter);
}
// Calculate future score.
@ -196,7 +199,8 @@ void SearchNormalBatch::EvalAndMergePartialHypos() {
for (dlm_iter = m_dlm_ffs.begin();
dlm_iter != m_dlm_ffs.end();
++dlm_iter) {
hypo->EvaluateWith((*dlm_iter).second, (*dlm_iter).first);
LanguageModel &lm = *(dlm_iter->second);
hypo->EvaluateWith(lm, (*dlm_iter).first);
}
// Calculate the final score.