From efdb8566b17d19783aa65caf22b24e48a789fbb8 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 2 Jun 2015 21:00:32 +0400 Subject: [PATCH] delete ChangeSource(). Not used --- contrib/other-builds/all.workspace | 1 - contrib/other-builds/moses/moses.project | 8 +- moses-cmd/MainVW.cpp | 3 - moses/ExportInterface.cpp | 4 - moses/FF/Factory.cpp | 2 - moses/FF/FeatureFunction.cpp | 14 ---- moses/FF/FeatureFunction.h | 6 -- moses/FF/SkeletonChangeInput.cpp | 96 ------------------------ moses/FF/SkeletonChangeInput.h | 45 ----------- 9 files changed, 3 insertions(+), 176 deletions(-) delete mode 100644 moses/FF/SkeletonChangeInput.cpp delete mode 100644 moses/FF/SkeletonChangeInput.h diff --git a/contrib/other-builds/all.workspace b/contrib/other-builds/all.workspace index 3df758293..66dafe3d2 100644 --- a/contrib/other-builds/all.workspace +++ b/contrib/other-builds/all.workspace @@ -1,6 +1,5 @@ - diff --git a/contrib/other-builds/moses/moses.project b/contrib/other-builds/moses/moses.project index 2c2affd45..f902dd1f4 100644 --- a/contrib/other-builds/moses/moses.project +++ b/contrib/other-builds/moses/moses.project @@ -1,6 +1,9 @@ + + + - - - @@ -531,8 +531,6 @@ - - diff --git a/moses-cmd/MainVW.cpp b/moses-cmd/MainVW.cpp index ac54c1ed6..c8047c201 100644 --- a/moses-cmd/MainVW.cpp +++ b/moses-cmd/MainVW.cpp @@ -151,9 +151,6 @@ int main(int argc, char** argv) ResetUserTime(); } - InputType* foo = source.get(); - FeatureFunction::CallChangeSource(foo); - // set up task of training one sentence boost::shared_ptr task; task = TrainingTask::create(source, ioWrapper); diff --git a/moses/ExportInterface.cpp b/moses/ExportInterface.cpp index 0ceeceec1..c444e98c9 100644 --- a/moses/ExportInterface.cpp +++ b/moses/ExportInterface.cpp @@ -118,8 +118,6 @@ string SimpleTranslationInterface::translate(const string &inputString) ResetUserTime(); } - FeatureFunction::CallChangeSource(&*source); - // set up task of translating one sentence boost::shared_ptr task = TranslationTask::create(source, ioWrapper); @@ -223,8 +221,6 @@ batch_run() while ((source = ioWrapper->ReadInput()) != NULL) { IFVERBOSE(1) ResetUserTime(); - FeatureFunction::CallChangeSource(source.get()); - // set up task of translating one sentence boost::shared_ptr task = TranslationTask::create(source, ioWrapper); diff --git a/moses/FF/Factory.cpp b/moses/FF/Factory.cpp index c797381ff..167e02370 100644 --- a/moses/FF/Factory.cpp +++ b/moses/FF/Factory.cpp @@ -62,7 +62,6 @@ #include "moses/LM/SkeletonLM.h" #include "moses/FF/SkeletonTranslationOptionListFeature.h" #include "moses/LM/BilingualLM.h" -#include "SkeletonChangeInput.h" #include "moses/TranslationModel/SkeletonPT.h" #include "moses/Syntax/InputWeightFF.h" #include "moses/Syntax/RuleTableFF.h" @@ -268,7 +267,6 @@ FeatureRegistry::FeatureRegistry() MOSES_FNAME(SkeletonStatelessFF); MOSES_FNAME(SkeletonStatefulFF); MOSES_FNAME(SkeletonLM); - MOSES_FNAME(SkeletonChangeInput); MOSES_FNAME(SkeletonTranslationOptionListFeature); MOSES_FNAME(SkeletonPT); diff --git a/moses/FF/FeatureFunction.cpp b/moses/FF/FeatureFunction.cpp index 5eab202ae..08ad26db8 100644 --- a/moses/FF/FeatureFunction.cpp +++ b/moses/FF/FeatureFunction.cpp @@ -38,20 +38,6 @@ void FeatureFunction::Destroy() RemoveAllInColl(s_staticColl); } -// The original declaration as -// void FeatureFunction::CallChangeSource(InputType *&input) -// had me a bit perplexed. Would you really want to allow -// any feature function to replace the InputType behind the -// back of the others? And change what the vector is pointing to? - -void FeatureFunction::CallChangeSource(InputType * const&input) -{ - for (size_t i = 0; i < s_staticColl.size(); ++i) { - const FeatureFunction &ff = *s_staticColl[i]; - ff.ChangeSource(input); - } -} - void FeatureFunction::SetupAll(TranslationTask const& ttask) { BOOST_FOREACH(FeatureFunction* ff, s_staticColl) diff --git a/moses/FF/FeatureFunction.h b/moses/FF/FeatureFunction.h index d3d6ab168..c95b5eb25 100644 --- a/moses/FF/FeatureFunction.h +++ b/moses/FF/FeatureFunction.h @@ -62,9 +62,6 @@ public: static FeatureFunction &FindFeatureFunction(const std::string& name); static void Destroy(); - static void CallChangeSource(InputType * const&input); - // see my note in FeatureFunction.cpp --- UG - FeatureFunction(const std::string &line, bool initializeNow); FeatureFunction(size_t numScoreComponents, const std::string &line); virtual bool IsStateless() const = 0; @@ -156,9 +153,6 @@ public: ScoreComponentCollection& scoreBreakdown, ScoreComponentCollection& estimatedFutureScore) const = 0; - // override this method if you want to change the input before decoding - virtual void ChangeSource(InputType * const&input) const { } - // for context-dependent processing static void SetupAll(TranslationTask const& task); virtual void Setup(TranslationTask const& task) const { }; diff --git a/moses/FF/SkeletonChangeInput.cpp b/moses/FF/SkeletonChangeInput.cpp deleted file mode 100644 index 7937d7771..000000000 --- a/moses/FF/SkeletonChangeInput.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include -#include "SkeletonChangeInput.h" -#include "moses/ScoreComponentCollection.h" -#include "moses/TargetPhrase.h" -#include "moses/Sentence.h" -#include "moses/FactorCollection.h" -#include "util/exception.hh" - -using namespace std; - -namespace Moses -{ -SkeletonChangeInput::SkeletonChangeInput(const std::string &line) - :StatelessFeatureFunction(2, line) -{ - ReadParameters(); -} - -void SkeletonChangeInput::EvaluateInIsolation(const Phrase &source - , const TargetPhrase &targetPhrase - , ScoreComponentCollection &scoreBreakdown - , ScoreComponentCollection &estimatedFutureScore) const -{ - // dense scores - vector newScores(m_numScoreComponents); - newScores[0] = 1.5; - newScores[1] = 0.3; - scoreBreakdown.PlusEquals(this, newScores); - - // sparse scores - scoreBreakdown.PlusEquals(this, "sparse-name", 2.4); - -} - -void SkeletonChangeInput::EvaluateWithSourceContext(const InputType &input - , const InputPath &inputPath - , const TargetPhrase &targetPhrase - , const StackVec *stackVec - , ScoreComponentCollection &scoreBreakdown - , ScoreComponentCollection *estimatedFutureScore) const -{ - if (targetPhrase.GetNumNonTerminals()) { - vector newScores(m_numScoreComponents); - newScores[0] = - std::numeric_limits::infinity(); - scoreBreakdown.PlusEquals(this, newScores); - } - -} - -void SkeletonChangeInput::EvaluateTranslationOptionListWithSourceContext(const InputType &input - , const TranslationOptionList &translationOptionList) const -{} - -void SkeletonChangeInput::EvaluateWhenApplied(const Hypothesis& hypo, - ScoreComponentCollection* accumulator) const -{} - -void SkeletonChangeInput::EvaluateWhenApplied(const ChartHypothesis &hypo, - ScoreComponentCollection* accumulator) const -{} - -void SkeletonChangeInput::ChangeSource(InputType* const& input) const -{ - // add factor[1] to each word. Created from first 4 letter of factor[0] - - Sentence *sentence = dynamic_cast(input); - UTIL_THROW_IF2(sentence == NULL, "Not a sentence input"); - - FactorCollection &fc = FactorCollection::Instance(); - - size_t size = sentence->GetSize(); - for (size_t i = 0; i < size; ++i) { - Word &word = sentence->Phrase::GetWord(i); - const Factor *factor0 = word[0]; - - std::string str = factor0->GetString().as_string(); - if (str.length() > 4) { - str = str.substr(0, 4); - } - - const Factor *factor1 = fc.AddFactor(str); - word.SetFactor(1, factor1); - } -} - -void SkeletonChangeInput::SetParameter(const std::string& key, const std::string& value) -{ - if (key == "arg") { - // set value here - } else { - StatelessFeatureFunction::SetParameter(key, value); - } -} - -} - diff --git a/moses/FF/SkeletonChangeInput.h b/moses/FF/SkeletonChangeInput.h deleted file mode 100644 index f8d9010ce..000000000 --- a/moses/FF/SkeletonChangeInput.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include -#include "StatelessFeatureFunction.h" - -namespace Moses -{ - -class SkeletonChangeInput : public StatelessFeatureFunction -{ -public: - SkeletonChangeInput(const std::string &line); - - bool IsUseable(const FactorMask &mask) const { - return true; - } - - void EvaluateInIsolation(const Phrase &source - , const TargetPhrase &targetPhrase - , ScoreComponentCollection &scoreBreakdown - , ScoreComponentCollection &estimatedFutureScore) const; - - void ChangeSource(InputType* const&input) const; - - void EvaluateWithSourceContext(const InputType &input - , const InputPath &inputPath - , const TargetPhrase &targetPhrase - , const StackVec *stackVec - , ScoreComponentCollection &scoreBreakdown - , ScoreComponentCollection *estimatedFutureScore = NULL) const; - - void EvaluateTranslationOptionListWithSourceContext(const InputType &input - , const TranslationOptionList &translationOptionList) const; - - void EvaluateWhenApplied(const Hypothesis& hypo, - ScoreComponentCollection* accumulator) const; - void EvaluateWhenApplied(const ChartHypothesis &hypo, - ScoreComponentCollection* accumulator) const; - - void SetParameter(const std::string& key, const std::string& value); - -}; - -} -