From c99e9f8c908ab7204e796745adfd1592d72ddf0f Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Thu, 2 May 2013 12:15:26 +0100 Subject: [PATCH] start framework for evaluating target phrase score --- moses/BleuScoreFeature.cpp | 7 +++++++ moses/BleuScoreFeature.h | 4 ++++ moses/DecodeFeature.h | 8 ++++++++ moses/DummyScoreProducers.cpp | 21 +++++++++++++++++++++ moses/DummyScoreProducers.h | 18 ++++++++++++++++++ moses/FeatureFunction.h | 7 +++++++ moses/GlobalLexicalModel.cpp | 10 +++++++++- moses/GlobalLexicalModel.h | 5 +++++ moses/GlobalLexicalModelUnlimited.cpp | 7 +++++++ moses/GlobalLexicalModelUnlimited.h | 3 +++ moses/LM/Base.cpp | 7 +++++++ moses/LM/Base.h | 5 +++++ moses/LM/Implementation.cpp | 1 - moses/LexicalReordering.cpp | 7 +++++++ moses/LexicalReordering.h | 12 ++++++++---- moses/PhraseBoundaryFeature.cpp | 7 +++++++ moses/PhraseBoundaryFeature.h | 5 ++++- moses/PhraseLengthFeature.cpp | 7 +++++++ moses/PhraseLengthFeature.h | 4 ++++ moses/PhrasePairFeature.cpp | 7 +++++++ moses/PhrasePairFeature.h | 4 ++++ moses/ScoreComponentCollectionTest.cpp | 5 +++++ moses/SourceWordDeletionFeature.cpp | 7 +++++++ moses/SourceWordDeletionFeature.h | 4 ++++ moses/TargetBigramFeature.cpp | 8 ++++++++ moses/TargetBigramFeature.h | 5 +++++ moses/TargetNgramFeature.cpp | 7 +++++++ moses/TargetNgramFeature.h | 4 ++++ moses/TargetPhrase.cpp | 14 ++++++++++++++ moses/TargetPhrase.h | 2 ++ moses/TargetWordInsertionFeature.cpp | 7 +++++++ moses/TargetWordInsertionFeature.h | 4 ++++ moses/WordTranslationFeature.cpp | 7 +++++++ moses/WordTranslationFeature.h | 4 ++++ 34 files changed, 227 insertions(+), 7 deletions(-) diff --git a/moses/BleuScoreFeature.cpp b/moses/BleuScoreFeature.cpp index 6339d498b..1319e6743 100644 --- a/moses/BleuScoreFeature.cpp +++ b/moses/BleuScoreFeature.cpp @@ -858,5 +858,12 @@ const FFState* BleuScoreFeature::EmptyHypothesisState(const InputType& input) co return new BleuScoreState(); } +void BleuScoreFeature::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } // namespace. diff --git a/moses/BleuScoreFeature.h b/moses/BleuScoreFeature.h index fb6fd944d..8049cde06 100644 --- a/moses/BleuScoreFeature.h +++ b/moses/BleuScoreFeature.h @@ -118,6 +118,10 @@ public: float GetTargetLengthHistory() { return m_target_length_history; } float GetAverageInputLength() { return m_avg_input_length; } + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + private: bool m_enabled; bool m_sentence_bleu; diff --git a/moses/DecodeFeature.h b/moses/DecodeFeature.h index d1fdf6858..f9ed5364a 100644 --- a/moses/DecodeFeature.h +++ b/moses/DecodeFeature.h @@ -58,7 +58,15 @@ class DecodeFeature : public StatelessFeatureFunction { const std::vector& GetInput() const; const std::vector& GetOutput() const; + + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const + {} + bool IsDecodeFeature() const + { return true; } + protected: std::vector m_input; std::vector m_output; diff --git a/moses/DummyScoreProducers.cpp b/moses/DummyScoreProducers.cpp index c427e1b7b..a82ab31a9 100644 --- a/moses/DummyScoreProducers.cpp +++ b/moses/DummyScoreProducers.cpp @@ -101,6 +101,13 @@ FFState* DistortionScoreProducer::Evaluate( return res; } +void DistortionScoreProducer::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + void WordPenaltyProducer::Evaluate( const PhraseBasedFeatureContext& context, ScoreComponentCollection* out) const @@ -109,4 +116,18 @@ void WordPenaltyProducer::Evaluate( out->PlusEquals(this, -static_cast(tp.GetSize())); } +void WordPenaltyProducer::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + +void UnknownWordPenaltyProducer::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } diff --git a/moses/DummyScoreProducers.h b/moses/DummyScoreProducers.h index 45bc55d23..90783b95b 100644 --- a/moses/DummyScoreProducers.h +++ b/moses/DummyScoreProducers.h @@ -37,6 +37,11 @@ public: CHECK(0); // feature function not valid in chart decoder return NULL; } + + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + }; /** Doesn't do anything but provide a key into the global @@ -57,6 +62,11 @@ public: { //required but does nothing. } + + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + }; /** unknown word penalty */ @@ -78,6 +88,10 @@ public: //do nothing - not a real feature } + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + virtual bool IsTuneable() const { return false; } }; @@ -98,6 +112,10 @@ class MetaFeatureProducer : public StatelessFeatureFunction ScoreComponentCollection*) const { //do nothing - not a real feature } + + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; }; } diff --git a/moses/FeatureFunction.h b/moses/FeatureFunction.h index 5dd3600e4..8ae18cb9c 100644 --- a/moses/FeatureFunction.h +++ b/moses/FeatureFunction.h @@ -132,6 +132,13 @@ public: const std::string &GetArgLine() const { return m_argLine; } + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const = 0; + + virtual bool IsDecodeFeature() const + { return false; } + }; /** base class for all stateless feature functions. diff --git a/moses/GlobalLexicalModel.cpp b/moses/GlobalLexicalModel.cpp index 6171c9244..6d2d7528a 100644 --- a/moses/GlobalLexicalModel.cpp +++ b/moses/GlobalLexicalModel.cpp @@ -178,11 +178,19 @@ float GlobalLexicalModel::GetFromCacheOrScorePhrase( const TargetPhrase& targetP return score; } - void GlobalLexicalModel::Evaluate +void GlobalLexicalModel::Evaluate (const PhraseBasedFeatureContext& context, ScoreComponentCollection* accumulator) const { accumulator->PlusEquals( this, GetFromCacheOrScorePhrase(context.GetTargetPhrase()) ); } + +void GlobalLexicalModel::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } diff --git a/moses/GlobalLexicalModel.h b/moses/GlobalLexicalModel.h index 72c4ec325..26aba137e 100644 --- a/moses/GlobalLexicalModel.h +++ b/moses/GlobalLexicalModel.h @@ -79,6 +79,11 @@ public: exit(1); } + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + + virtual StatelessFeatureType GetStatelessFeatureType() const { return DependsOnSource; } diff --git a/moses/GlobalLexicalModelUnlimited.cpp b/moses/GlobalLexicalModelUnlimited.cpp index 56b6d46bc..219bfed84 100644 --- a/moses/GlobalLexicalModelUnlimited.cpp +++ b/moses/GlobalLexicalModelUnlimited.cpp @@ -334,4 +334,11 @@ void GlobalLexicalModelUnlimited::AddFeature(ScoreComponentCollection* accumulat } +void GlobalLexicalModelUnlimited::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } diff --git a/moses/GlobalLexicalModelUnlimited.h b/moses/GlobalLexicalModelUnlimited.h index fde71b807..7491fb918 100644 --- a/moses/GlobalLexicalModelUnlimited.h +++ b/moses/GlobalLexicalModelUnlimited.h @@ -89,6 +89,9 @@ public: assert(0); } + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; void SetSparseProducerWeight(float weight) { m_sparseProducerWeight = weight; } float GetSparseProducerWeight() const { return m_sparseProducerWeight; } diff --git a/moses/LM/Base.cpp b/moses/LM/Base.cpp index 373ce557e..7038e5630 100644 --- a/moses/LM/Base.cpp +++ b/moses/LM/Base.cpp @@ -60,4 +60,11 @@ void LanguageModel::IncrementalCallback(Incremental::Manager &manager) const { UTIL_THROW(util::Exception, "Incremental search is only supported by KenLM."); } +void LanguageModel::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } // namespace Moses diff --git a/moses/LM/Base.h b/moses/LM/Base.h index 982ebbffe..0841c7f1c 100644 --- a/moses/LM/Base.h +++ b/moses/LM/Base.h @@ -85,6 +85,11 @@ public: // KenLM only (others throw an exception): call incremental search with the model and mapping. virtual void IncrementalCallback(Incremental::Manager &manager) const; + + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + }; } diff --git a/moses/LM/Implementation.cpp b/moses/LM/Implementation.cpp index 44432ae4a..8f130b158 100644 --- a/moses/LM/Implementation.cpp +++ b/moses/LM/Implementation.cpp @@ -222,7 +222,6 @@ FFState* LanguageModelImplementation::EvaluateChart(const ChartHypothesis& hypo, float finalizedScore = 0.0; // finalized, has sufficient context // get index map for underlying hypotheses - const TargetPhrase &target = hypo.GetCurrTargetPhrase(); const AlignmentInfo::NonTermIndexMap &nonTermIndexMap = hypo.GetCurrTargetPhrase().GetAlignNonTerm().GetNonTermIndexMap(); diff --git a/moses/LexicalReordering.cpp b/moses/LexicalReordering.cpp index efdda129f..5de76977e 100644 --- a/moses/LexicalReordering.cpp +++ b/moses/LexicalReordering.cpp @@ -95,5 +95,12 @@ const FFState* LexicalReordering::EmptyHypothesisState(const InputType &input) c return m_configuration->CreateLexicalReorderingState(input); } +void LexicalReordering::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } diff --git a/moses/LexicalReordering.h b/moses/LexicalReordering.h index 6e24f82b7..91b0ac71e 100644 --- a/moses/LexicalReordering.h +++ b/moses/LexicalReordering.h @@ -28,10 +28,6 @@ public: LexicalReordering(const std::string &line); virtual ~LexicalReordering(); - virtual FFState* Evaluate(const Hypothesis& cur_hypo, - const FFState* prev_state, - ScoreComponentCollection* accumulator) const; - virtual const FFState* EmptyHypothesisState(const InputType &input) const; void InitializeForInput(const InputType& i){ @@ -40,6 +36,10 @@ public: Scores GetProb(const Phrase& f, const Phrase& e) const; + virtual FFState* Evaluate(const Hypothesis& cur_hypo, + const FFState* prev_state, + ScoreComponentCollection* accumulator) const; + virtual FFState* EvaluateChart(const ChartHypothesis&, int /* featureID */, ScoreComponentCollection*) const { @@ -47,6 +47,10 @@ public: return NULL; } + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + private: bool DecodeCondition(std::string s); bool DecodeDirection(std::string s); diff --git a/moses/PhraseBoundaryFeature.cpp b/moses/PhraseBoundaryFeature.cpp index 7c8dd0b32..d955a341b 100644 --- a/moses/PhraseBoundaryFeature.cpp +++ b/moses/PhraseBoundaryFeature.cpp @@ -94,5 +94,12 @@ FFState* PhraseBoundaryFeature::Evaluate return new PhraseBoundaryState(endSourceWord,endTargetWord); } +void PhraseBoundaryFeature::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } diff --git a/moses/PhraseBoundaryFeature.h b/moses/PhraseBoundaryFeature.h index 43852e063..80c954645 100644 --- a/moses/PhraseBoundaryFeature.h +++ b/moses/PhraseBoundaryFeature.h @@ -46,7 +46,10 @@ public: { abort(); } - + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + void SetSparseProducerWeight(float weight) { m_sparseProducerWeight = weight; } float GetSparseProducerWeight() const { return m_sparseProducerWeight; } diff --git a/moses/PhraseLengthFeature.cpp b/moses/PhraseLengthFeature.cpp index 296abb6c1..e031737b3 100644 --- a/moses/PhraseLengthFeature.cpp +++ b/moses/PhraseLengthFeature.cpp @@ -40,4 +40,11 @@ void PhraseLengthFeature::Evaluate( //cerr << nameSource.str() << " " << nameTarget.str() << " " << nameBoth.str() << endl; } +void PhraseLengthFeature::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } diff --git a/moses/PhraseLengthFeature.h b/moses/PhraseLengthFeature.h index 59f264307..0656eef07 100644 --- a/moses/PhraseLengthFeature.h +++ b/moses/PhraseLengthFeature.h @@ -27,6 +27,10 @@ public: throw std::logic_error("PhraseLengthFeature not valid in chart decoder"); } + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + }; } diff --git a/moses/PhrasePairFeature.cpp b/moses/PhrasePairFeature.cpp index 0f12c7376..d4ed04949 100644 --- a/moses/PhrasePairFeature.cpp +++ b/moses/PhrasePairFeature.cpp @@ -244,4 +244,11 @@ void PhrasePairFeature::Evaluate( } } +void PhrasePairFeature::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } diff --git a/moses/PhrasePairFeature.h b/moses/PhrasePairFeature.h index 48acade9f..c4a1eea2b 100644 --- a/moses/PhrasePairFeature.h +++ b/moses/PhrasePairFeature.h @@ -41,6 +41,10 @@ class PhrasePairFeature: public StatelessFeatureFunction { throw std::logic_error("PhrasePairFeature not valid in chart decoder"); } + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + bool Load(const std::string &filePathSource/*, const std::string &filePathTarget*/); void SetSparseProducerWeight(float weight) { m_sparseProducerWeight = weight; } diff --git a/moses/ScoreComponentCollectionTest.cpp b/moses/ScoreComponentCollectionTest.cpp index 7da5cd1ec..69d099edd 100644 --- a/moses/ScoreComponentCollectionTest.cpp +++ b/moses/ScoreComponentCollectionTest.cpp @@ -36,6 +36,10 @@ class MockStatelessFeatureFunction : public StatelessFeatureFunction { StatelessFeatureFunction(desc,n, line) {} virtual void Evaluate(const PhraseBasedFeatureContext&, ScoreComponentCollection*) const {} virtual void EvaluateChart(const ChartBasedFeatureContext&, ScoreComponentCollection*) const {} + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const + { } }; class MockSingleFeature : public MockStatelessFeatureFunction { @@ -54,6 +58,7 @@ class MockSparseFeature : public MockStatelessFeatureFunction { }; + struct MockProducers { MockProducers() {} diff --git a/moses/SourceWordDeletionFeature.cpp b/moses/SourceWordDeletionFeature.cpp index 9a1eafceb..ea9b3b53b 100644 --- a/moses/SourceWordDeletionFeature.cpp +++ b/moses/SourceWordDeletionFeature.cpp @@ -80,6 +80,13 @@ void SourceWordDeletionFeature::EvaluateChart( ComputeFeatures(context.GetTargetPhrase(), accumulator, alignmentInfo); } +void SourceWordDeletionFeature::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + void SourceWordDeletionFeature::ComputeFeatures(const TargetPhrase& targetPhrase, ScoreComponentCollection* accumulator, const AlignmentInfo &alignmentInfo) const diff --git a/moses/SourceWordDeletionFeature.h b/moses/SourceWordDeletionFeature.h index d556e78cb..fc68b429a 100644 --- a/moses/SourceWordDeletionFeature.h +++ b/moses/SourceWordDeletionFeature.h @@ -29,6 +29,10 @@ public: void EvaluateChart(const ChartBasedFeatureContext& context, ScoreComponentCollection* accumulator) const; + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + void ComputeFeatures(const TargetPhrase& targetPhrase, ScoreComponentCollection* accumulator, const AlignmentInfo &alignmentInfo) const; diff --git a/moses/TargetBigramFeature.cpp b/moses/TargetBigramFeature.cpp index 27922ab15..e55a29cad 100644 --- a/moses/TargetBigramFeature.cpp +++ b/moses/TargetBigramFeature.cpp @@ -111,5 +111,13 @@ FFState* TargetBigramFeature::Evaluate(const Hypothesis& cur_hypo, } return new TargetBigramState(targetPhrase.GetWord(targetPhrase.GetSize()-1)); } + +void TargetBigramFeature::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } diff --git a/moses/TargetBigramFeature.h b/moses/TargetBigramFeature.h index 5f1fbbc65..62b8da842 100644 --- a/moses/TargetBigramFeature.h +++ b/moses/TargetBigramFeature.h @@ -41,6 +41,11 @@ public: { abort(); } + + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + private: FactorType m_factorType; Word m_bos; diff --git a/moses/TargetNgramFeature.cpp b/moses/TargetNgramFeature.cpp index 4830f4726..aafa0ecff 100644 --- a/moses/TargetNgramFeature.cpp +++ b/moses/TargetNgramFeature.cpp @@ -394,6 +394,13 @@ FFState* TargetNgramFeature::EvaluateChart(const ChartHypothesis& cur_hypo, int return new TargetNgramChartState(cur_hypo, featureId, m_n); } +void TargetNgramFeature::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + void TargetNgramFeature::MakePrefixNgrams(std::vector &contextFactor, ScoreComponentCollection* accumulator, size_t numberOfStartPos, size_t offset) const { stringstream ngram; size_t size = contextFactor.size(); diff --git a/moses/TargetNgramFeature.h b/moses/TargetNgramFeature.h index b8ddf23f9..1c2cf9c41 100644 --- a/moses/TargetNgramFeature.h +++ b/moses/TargetNgramFeature.h @@ -195,6 +195,10 @@ public: virtual FFState* EvaluateChart(const ChartHypothesis& cur_hypo, int featureId, ScoreComponentCollection* accumulator) const; + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + private: FactorType m_factorType; Word m_bos; diff --git a/moses/TargetPhrase.cpp b/moses/TargetPhrase.cpp index 10934ac4d..7f01d32ca 100644 --- a/moses/TargetPhrase.cpp +++ b/moses/TargetPhrase.cpp @@ -78,7 +78,21 @@ void TargetPhrase::WriteToRulePB(hgmert::Rule* pb) const } #endif +void TargetPhrase::Evaluate() +{ + float totalEstFutureScore = 0; + const std::vector &ffs = FeatureFunction::GetFeatureFunctions(); + + for (size_t i = 0; i < ffs.size(); ++i) { + const FeatureFunction &ff = *ffs[i]; + if (!ff.IsDecodeFeature()) { + float estimatedFutureScore = 0; + ff.Evaluate(*this, m_scoreBreakdown, estimatedFutureScore); + totalEstFutureScore += estimatedFutureScore; + } + } +} void TargetPhrase::SetScore(float score) { diff --git a/moses/TargetPhrase.h b/moses/TargetPhrase.h index 5ced75e1d..8ab356f61 100644 --- a/moses/TargetPhrase.h +++ b/moses/TargetPhrase.h @@ -61,6 +61,8 @@ public: explicit TargetPhrase(std::string out_string); explicit TargetPhrase(const Phrase &targetPhrase); + void Evaluate(); + //!Set score for Sentence XML target options void SetScore(float score); diff --git a/moses/TargetWordInsertionFeature.cpp b/moses/TargetWordInsertionFeature.cpp index 6a2552a20..7979063d7 100644 --- a/moses/TargetWordInsertionFeature.cpp +++ b/moses/TargetWordInsertionFeature.cpp @@ -84,6 +84,13 @@ void TargetWordInsertionFeature::EvaluateChart( ComputeFeatures(targetPhrase, accumulator, alignmentInfo); } +void TargetWordInsertionFeature::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + void TargetWordInsertionFeature::ComputeFeatures(const TargetPhrase& targetPhrase, ScoreComponentCollection* accumulator, const AlignmentInfo &alignmentInfo) const diff --git a/moses/TargetWordInsertionFeature.h b/moses/TargetWordInsertionFeature.h index de5af3eaa..17ebd1cc4 100644 --- a/moses/TargetWordInsertionFeature.h +++ b/moses/TargetWordInsertionFeature.h @@ -29,6 +29,10 @@ public: void EvaluateChart( const ChartBasedFeatureContext& context, ScoreComponentCollection* accumulator) const; + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + void ComputeFeatures(const TargetPhrase& targetPhrase, ScoreComponentCollection* accumulator, const AlignmentInfo &alignmentInfo) const; diff --git a/moses/WordTranslationFeature.cpp b/moses/WordTranslationFeature.cpp index 52234c18d..984bc475d 100644 --- a/moses/WordTranslationFeature.cpp +++ b/moses/WordTranslationFeature.cpp @@ -528,4 +528,11 @@ void WordTranslationFeature::EvaluateChart( } +void WordTranslationFeature::Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const +{ + CHECK(false); +} + } diff --git a/moses/WordTranslationFeature.h b/moses/WordTranslationFeature.h index 1e197ee6b..751151fd6 100644 --- a/moses/WordTranslationFeature.h +++ b/moses/WordTranslationFeature.h @@ -50,6 +50,10 @@ public: void EvaluateChart(const ChartBasedFeatureContext& context, ScoreComponentCollection* accumulator) const; + virtual void Evaluate(const TargetPhrase &targetPhrase + , ScoreComponentCollection &scoreBreakdown + , float &estimatedFutureScore) const; + void SetSparseProducerWeight(float weight) { m_sparseProducerWeight = weight; } float GetSparseProducerWeight() const { return m_sparseProducerWeight; }