diff --git a/contrib/other-builds/moses/.project b/contrib/other-builds/moses/.project
index 0ae0ca19f..99d40167b 100644
--- a/contrib/other-builds/moses/.project
+++ b/contrib/other-builds/moses/.project
@@ -1171,16 +1171,6 @@
2
virtual:/virtual
-
- FF/PhraseBasedFeatureContext.cpp
- 1
- PARENT-3-PROJECT_LOC/moses/FF/PhraseBasedFeatureContext.cpp
-
-
- FF/PhraseBasedFeatureContext.h
- 1
- PARENT-3-PROJECT_LOC/moses/FF/PhraseBasedFeatureContext.h
-
FF/PhraseBoundaryFeature.cpp
1
diff --git a/moses/FF/ChartBasedFeatureContext.h b/moses/FF/ChartBasedFeatureContext.h
index a204f7c77..c8c7e2122 100644
--- a/moses/FF/ChartBasedFeatureContext.h
+++ b/moses/FF/ChartBasedFeatureContext.h
@@ -6,9 +6,6 @@ class ChartHypothesis;
class InputType;
class TargetPhrase;
-/**
- * Same as PhraseBasedFeatureContext, but for chart-based Moses.
- **/
class ChartBasedFeatureContext
{
//The context either has a hypothesis (during search) or a
diff --git a/moses/FF/FeatureFunction.h b/moses/FF/FeatureFunction.h
index 0ce62973a..49adb52b5 100644
--- a/moses/FF/FeatureFunction.h
+++ b/moses/FF/FeatureFunction.h
@@ -4,7 +4,6 @@
#include
#include
#include
-#include "PhraseBasedFeatureContext.h"
#include "ChartBasedFeatureContext.h"
#include "moses/TypeDef.h"
diff --git a/moses/FF/GlobalLexicalModel.cpp b/moses/FF/GlobalLexicalModel.cpp
index 0f952b810..15b5f7531 100644
--- a/moses/FF/GlobalLexicalModel.cpp
+++ b/moses/FF/GlobalLexicalModel.cpp
@@ -167,11 +167,11 @@ float GlobalLexicalModel::GetFromCacheOrScorePhrase( const TargetPhrase& targetP
}
void GlobalLexicalModel::Evaluate
-(const PhraseBasedFeatureContext& context,
+(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const
{
accumulator->PlusEquals( this,
- GetFromCacheOrScorePhrase(context.GetHypothesis().GetCurrTargetPhrase()) );
+ GetFromCacheOrScorePhrase(hypo.GetCurrTargetPhrase()) );
}
bool GlobalLexicalModel::IsUseable(const FactorMask &mask) const
diff --git a/moses/FF/GlobalLexicalModel.h b/moses/FF/GlobalLexicalModel.h
index 26e13c857..d31cc9f5a 100644
--- a/moses/FF/GlobalLexicalModel.h
+++ b/moses/FF/GlobalLexicalModel.h
@@ -68,7 +68,7 @@ public:
bool IsUseable(const FactorMask &mask) const;
- void Evaluate(const PhraseBasedFeatureContext& context,
+ void Evaluate(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const;
diff --git a/moses/FF/PhraseBasedFeatureContext.cpp b/moses/FF/PhraseBasedFeatureContext.cpp
deleted file mode 100644
index 9c8cc8ec8..000000000
--- a/moses/FF/PhraseBasedFeatureContext.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "PhraseBasedFeatureContext.h"
-#include "moses/Hypothesis.h"
-#include "moses/Manager.h"
-#include "moses/TranslationOption.h"
-
-namespace Moses
-{
-PhraseBasedFeatureContext::PhraseBasedFeatureContext(const Hypothesis* hypothesis) :
- m_hypothesis(hypothesis),
- m_translationOption(m_hypothesis->GetTranslationOption()),
- m_source(m_hypothesis->GetManager().GetSource()) {}
-
-
-}
diff --git a/moses/FF/PhraseBasedFeatureContext.h b/moses/FF/PhraseBasedFeatureContext.h
deleted file mode 100644
index 62eb629a7..000000000
--- a/moses/FF/PhraseBasedFeatureContext.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#pragma once
-
-namespace Moses
-{
-class Hypothesis;
-class TranslationOption;
-class InputType;
-class TargetPhrase;
-class WordsBitmap;
-
-/**
- * Contains all that a feature function can access without affecting recombination.
- * For stateless features, this is all that it can access. Currently this is not
- * used for stateful features, as it would need to be retro-fitted to the LM feature.
- * TODO: Expose source segmentation,lattice path.
- * XXX Don't add anything to the context that would break recombination XXX
- **/
-class PhraseBasedFeatureContext
-{
- // The context either has a hypothesis (during search), or a TranslationOption and
- // source sentence (during pre-calculation).
- const Hypothesis* m_hypothesis;
- const TranslationOption& m_translationOption;
- const InputType& m_source;
-
-public:
- PhraseBasedFeatureContext(const Hypothesis* hypothesis);
-
- const Hypothesis& GetHypothesis() const {
- return *m_hypothesis;
- }
-
-};
-
-} // namespace
-
-
diff --git a/moses/FF/PhrasePairFeature.cpp b/moses/FF/PhrasePairFeature.cpp
index de566a3ce..017099371 100644
--- a/moses/FF/PhrasePairFeature.cpp
+++ b/moses/FF/PhrasePairFeature.cpp
@@ -106,11 +106,11 @@ void PhrasePairFeature::Load()
}
void PhrasePairFeature::Evaluate(
- const PhraseBasedFeatureContext& context,
+ const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const
{
- const TargetPhrase& target = context.GetHypothesis().GetCurrTargetPhrase();
- const Phrase& source = context.GetHypothesis().GetTranslationOption().GetInputPath().GetPhrase();
+ const TargetPhrase& target = hypo.GetCurrTargetPhrase();
+ const Phrase& source = hypo.GetTranslationOption().GetInputPath().GetPhrase();
if (m_simple) {
ostringstream namestr;
namestr << "pp_";
@@ -131,7 +131,7 @@ void PhrasePairFeature::Evaluate(
accumulator->SparsePlusEquals(namestr.str(),1);
}
if (m_domainTrigger) {
- const Sentence& input = static_cast(context.GetHypothesis().GetInput());
+ const Sentence& input = static_cast(hypo.GetInput());
const bool use_topicid = input.GetUseTopicId();
const bool use_topicid_prob = input.GetUseTopicIdAndProb();
@@ -199,7 +199,7 @@ void PhrasePairFeature::Evaluate(
}
}
if (m_sourceContext) {
- const Sentence& input = static_cast(context.GetHypothesis().GetInput());
+ const Sentence& input = static_cast(hypo.GetInput());
// range over source words to get context
for(size_t contextIndex = 0; contextIndex < input.GetSize(); contextIndex++ ) {
diff --git a/moses/FF/PhrasePairFeature.h b/moses/FF/PhrasePairFeature.h
index 6738992ee..6eb91ac12 100644
--- a/moses/FF/PhrasePairFeature.h
+++ b/moses/FF/PhrasePairFeature.h
@@ -37,7 +37,7 @@ public:
bool IsUseable(const FactorMask &mask) const;
- void Evaluate(const PhraseBasedFeatureContext& context,
+ void Evaluate(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const;
void EvaluateChart(const ChartBasedFeatureContext& context,
diff --git a/moses/FF/StatelessFeatureFunction.h b/moses/FF/StatelessFeatureFunction.h
index 1e2c6d450..fcad2137f 100644
--- a/moses/FF/StatelessFeatureFunction.h
+++ b/moses/FF/StatelessFeatureFunction.h
@@ -23,7 +23,7 @@ public:
/**
* This should be implemented for features that apply to phrase-based models.
**/
- virtual void Evaluate(const PhraseBasedFeatureContext& context,
+ virtual void Evaluate(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const {
}
diff --git a/moses/FF/WordTranslationFeature.cpp b/moses/FF/WordTranslationFeature.cpp
index 82815fd07..87af44254 100644
--- a/moses/FF/WordTranslationFeature.cpp
+++ b/moses/FF/WordTranslationFeature.cpp
@@ -137,12 +137,12 @@ void WordTranslationFeature::Load()
}
void WordTranslationFeature::Evaluate
-(const PhraseBasedFeatureContext& context,
+(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const
{
- const Sentence& input = static_cast(context.GetHypothesis().GetInput());
- const TranslationOption& transOpt = context.GetHypothesis().GetTranslationOption();
- const TargetPhrase& targetPhrase = context.GetHypothesis().GetCurrTargetPhrase();
+ const Sentence& input = static_cast(hypo.GetInput());
+ const TranslationOption& transOpt = hypo.GetTranslationOption();
+ const TargetPhrase& targetPhrase = hypo.GetCurrTargetPhrase();
const AlignmentInfo &alignment = targetPhrase.GetAlignTerm();
// process aligned words
@@ -243,7 +243,7 @@ void WordTranslationFeature::Evaluate
}
}
if (m_sourceContext) {
- size_t globalSourceIndex = context.GetHypothesis().GetTranslationOption().GetStartPos() + sourceIndex;
+ size_t globalSourceIndex = hypo.GetTranslationOption().GetStartPos() + sourceIndex;
if (!m_domainTrigger && globalSourceIndex == 0) {
// add trigger feature for source
stringstream feature;
diff --git a/moses/FF/WordTranslationFeature.h b/moses/FF/WordTranslationFeature.h
index d6bc7c06f..da3b06352 100644
--- a/moses/FF/WordTranslationFeature.h
+++ b/moses/FF/WordTranslationFeature.h
@@ -47,7 +47,7 @@ public:
return new DummyState();
}
- void Evaluate(const PhraseBasedFeatureContext& context,
+ void Evaluate(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const;
void EvaluateChart(const ChartBasedFeatureContext& context,
diff --git a/moses/Hypothesis.cpp b/moses/Hypothesis.cpp
index c472b8709..efbe03e03 100644
--- a/moses/Hypothesis.cpp
+++ b/moses/Hypothesis.cpp
@@ -263,7 +263,7 @@ void Hypothesis::EvaluateWith(const StatelessFeatureFunction& slff)
{
const StaticData &staticData = StaticData::Instance();
if (! staticData.IsFeatureFunctionIgnored( slff )) {
- slff.Evaluate(PhraseBasedFeatureContext(this), &m_scoreBreakdown);
+ slff.Evaluate(*this, &m_scoreBreakdown);
}
}
diff --git a/moses/ScoreComponentCollectionTest.cpp b/moses/ScoreComponentCollectionTest.cpp
index 4b5f20ae2..9182c9b0b 100644
--- a/moses/ScoreComponentCollectionTest.cpp
+++ b/moses/ScoreComponentCollectionTest.cpp
@@ -34,7 +34,7 @@ class MockStatelessFeatureFunction : public StatelessFeatureFunction
public:
MockStatelessFeatureFunction(const string& desc, size_t n, const string &line) :
StatelessFeatureFunction(desc,n, line) {}
- virtual void Evaluate(const PhraseBasedFeatureContext&, ScoreComponentCollection*) const {}
+ virtual void Evaluate(const Hypothesis&, ScoreComponentCollection*) const {}
virtual void EvaluateChart(const ChartBasedFeatureContext&, ScoreComponentCollection*) const {}
virtual void Evaluate(const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown