Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'moses/LM/IRST.cpp')
-rw-r--r--moses/LM/IRST.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/moses/LM/IRST.cpp b/moses/LM/IRST.cpp
index 4e4d66571..9448339aa 100644
--- a/moses/LM/IRST.cpp
+++ b/moses/LM/IRST.cpp
@@ -36,6 +36,7 @@ using namespace irstlm;
#include "moses/Phrase.h"
#include "moses/InputFileStream.h"
#include "moses/StaticData.h"
+#include "moses/TranslationTask.h"
using namespace std;
@@ -237,7 +238,7 @@ const FFState* LanguageModelIRST::EmptyHypothesisState(const InputType &/*input*
return ret.release();
}
-void LanguageModelIRST::CalcScore(const Phrase &phrase, float &fullScore, float &ngramScore, size_t &oovCount) const
+void LanguageModelIRST::CalcScoreWithContext(ttasksptr const& ttasks, const Phrase &phrase, float &fullScore, float &ngramScore, size_t &oovCount) const
{
fullScore = 0;
ngramScore = 0;
@@ -245,6 +246,9 @@ void LanguageModelIRST::CalcScore(const Phrase &phrase, float &fullScore, float
if ( !phrase.GetSize() ) return;
+ //get the context_weight map here
+ std::map<std::string, float> context_weight = ttasks->GetContextWeights();
+
int _min = min(m_lmtb_size - 1, (int) phrase.GetSize());
int codes[m_lmtb_size];
@@ -278,13 +282,16 @@ void LanguageModelIRST::CalcScore(const Phrase &phrase, float &fullScore, float
fullScore = ngramScore + before_boundary;
}
-FFState* LanguageModelIRST::EvaluateWhenApplied(const Hypothesis &hypo, const FFState *ps, ScoreComponentCollection *out) const
+FFState* LanguageModelIRST::EvaluateWhenAppliedWithContext(ttasksptr const& ttasks, const Hypothesis &hypo, const FFState *ps, ScoreComponentCollection *out) const
{
if (!hypo.GetCurrTargetLength()) {
std::auto_ptr<IRSTLMState> ret(new IRSTLMState(ps));
return ret.release();
}
+ //get the context_weight map here
+ std::map<std::string, float> context_weight = ttasks->GetContextWeights();
+
//[begin, end) in STL-like fashion.
const int begin = (const int) hypo.GetCurrTargetWordsRange().GetStartPos();
const int end = (const int) hypo.GetCurrTargetWordsRange().GetEndPos() + 1;