From 6ca7ba5de1ea93dd7ee04f3060614d5152a29c2d Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Wed, 26 Apr 2017 13:27:32 +0100 Subject: moses2 rename Skeleton... to Example... --- contrib/other-builds/moses2/.project | 40 +++++++-------- moses2/FF/ExampleStatefulFF.cpp | 96 ++++++++++++++++++++++++++++++++++++ moses2/FF/ExampleStatefulFF.h | 46 +++++++++++++++++ moses2/FF/ExampleStatelessFF.cpp | 40 +++++++++++++++ moses2/FF/ExampleStatelessFF.h | 34 +++++++++++++ moses2/FF/FeatureRegistry.cpp | 8 +-- moses2/FF/SkeletonStatefulFF.cpp | 96 ------------------------------------ moses2/FF/SkeletonStatefulFF.h | 48 ------------------ moses2/FF/SkeletonStatelessFF.cpp | 40 --------------- moses2/FF/SkeletonStatelessFF.h | 34 ------------- moses2/Jamfile | 4 +- 11 files changed, 242 insertions(+), 244 deletions(-) create mode 100644 moses2/FF/ExampleStatefulFF.cpp create mode 100644 moses2/FF/ExampleStatefulFF.h create mode 100644 moses2/FF/ExampleStatelessFF.cpp create mode 100644 moses2/FF/ExampleStatelessFF.h delete mode 100644 moses2/FF/SkeletonStatefulFF.cpp delete mode 100644 moses2/FF/SkeletonStatefulFF.h delete mode 100644 moses2/FF/SkeletonStatelessFF.cpp delete mode 100644 moses2/FF/SkeletonStatelessFF.h diff --git a/contrib/other-builds/moses2/.project b/contrib/other-builds/moses2/.project index 8677885e1..1588c88b6 100644 --- a/contrib/other-builds/moses2/.project +++ b/contrib/other-builds/moses2/.project @@ -357,6 +357,26 @@ 1 PARENT-3-PROJECT_LOC/moses2/FF/Distortion.h + + FF/ExampleStatefulFF.cpp + 1 + PARENT-3-PROJECT_LOC/moses2/FF/ExampleStatefulFF.cpp + + + FF/ExampleStatefulFF.h + 1 + PARENT-3-PROJECT_LOC/moses2/FF/ExampleStatefulFF.h + + + FF/ExampleStatelessFF.cpp + 1 + PARENT-3-PROJECT_LOC/moses2/FF/ExampleStatelessFF.cpp + + + FF/ExampleStatelessFF.h + 1 + PARENT-3-PROJECT_LOC/moses2/FF/ExampleStatelessFF.h + FF/FFState.cpp 1 @@ -427,26 +447,6 @@ 1 PARENT-3-PROJECT_LOC/moses2/FF/PointerState.h - - FF/SkeletonStatefulFF.cpp - 1 - PARENT-3-PROJECT_LOC/moses2/FF/SkeletonStatefulFF.cpp - - - FF/SkeletonStatefulFF.h - 1 - PARENT-3-PROJECT_LOC/moses2/FF/SkeletonStatefulFF.h - - - FF/SkeletonStatelessFF.cpp - 1 - PARENT-3-PROJECT_LOC/moses2/FF/SkeletonStatelessFF.cpp - - - FF/SkeletonStatelessFF.h - 1 - PARENT-3-PROJECT_LOC/moses2/FF/SkeletonStatelessFF.h - FF/StatefulFeatureFunction.cpp 1 diff --git a/moses2/FF/ExampleStatefulFF.cpp b/moses2/FF/ExampleStatefulFF.cpp new file mode 100644 index 000000000..86b364f53 --- /dev/null +++ b/moses2/FF/ExampleStatefulFF.cpp @@ -0,0 +1,96 @@ +/* + * ExampleStatefulFF.cpp + * + * Created on: 27 Oct 2015 + * Author: hieu + */ +#include +#include "ExampleStatefulFF.h" +#include "../PhraseBased/Manager.h" +#include "../PhraseBased/Hypothesis.h" + +using namespace std; + +namespace Moses2 +{ + +class ExampleState: public FFState +{ +public: + int targetLen; + + ExampleState() { + // uninitialised + } + + virtual size_t hash() const { + return (size_t) targetLen; + } + virtual bool operator==(const FFState& o) const { + const ExampleState& other = static_cast(o); + return targetLen == other.targetLen; + } + + virtual std::string ToString() const { + stringstream sb; + sb << targetLen; + return sb.str(); + } + +}; + +//////////////////////////////////////////////////////////////////////////////////////// +ExampleStatefulFF::ExampleStatefulFF(size_t startInd, const std::string &line) : + StatefulFeatureFunction(startInd, line) +{ + ReadParameters(); +} + +ExampleStatefulFF::~ExampleStatefulFF() +{ + // TODO Auto-generated destructor stub +} + +FFState* ExampleStatefulFF::BlankState(MemPool &pool, const System &sys) const +{ + return new (pool.Allocate()) ExampleState(); +} + +void ExampleStatefulFF::EmptyHypothesisState(FFState &state, + const ManagerBase &mgr, const InputType &input, + const Hypothesis &hypo) const +{ + ExampleState &stateCast = static_cast(state); + stateCast.targetLen = 0; +} + +void ExampleStatefulFF::EvaluateInIsolation(MemPool &pool, + const System &system, const Phrase &source, + const TargetPhraseImpl &targetPhrase, Scores &scores, + SCORE &estimatedScore) const +{ +} + +void ExampleStatefulFF::EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, + const TargetPhrase &targetPhrase, Scores &scores, + SCORE &estimatedScore) const +{ +} + +void ExampleStatefulFF::EvaluateWhenApplied(const ManagerBase &mgr, + const Hypothesis &hypo, const FFState &prevState, Scores &scores, + FFState &state) const +{ + ExampleState &stateCast = static_cast(state); + stateCast.targetLen = hypo.GetTargetPhrase().GetSize(); +} + +void ExampleStatefulFF::EvaluateWhenApplied(const SCFG::Manager &mgr, + const SCFG::Hypothesis &hypo, int featureID, Scores &scores, + FFState &state) const +{ + UTIL_THROW2("Not implemented"); +} + +} + diff --git a/moses2/FF/ExampleStatefulFF.h b/moses2/FF/ExampleStatefulFF.h new file mode 100644 index 000000000..437f54515 --- /dev/null +++ b/moses2/FF/ExampleStatefulFF.h @@ -0,0 +1,46 @@ +/* + * ExampleStatefulFF.h + * + * Created on: 27 Oct 2015 + * Author: hieu + */ + +#pragma once + +#include "StatefulFeatureFunction.h" + +namespace Moses2 +{ + +class ExampleStatefulFF: public StatefulFeatureFunction +{ +public: + ExampleStatefulFF(size_t startInd, const std::string &line); + virtual ~ExampleStatefulFF(); + + virtual FFState* BlankState(MemPool &pool, const System &sys) const; + virtual void EmptyHypothesisState(FFState &state, const ManagerBase &mgr, + const InputType &input, const Hypothesis &hypo) const; + + virtual void + EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, + const TargetPhraseImpl &targetPhrase, Scores &scores, + SCORE &estimatedScore) const; + + virtual void + EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, + const TargetPhrase &targetPhrase, Scores &scores, + SCORE &estimatedScore) const; + + virtual void EvaluateWhenApplied(const ManagerBase &mgr, + const Hypothesis &hypo, const FFState &prevState, Scores &scores, + FFState &state) const; + + virtual void EvaluateWhenApplied(const SCFG::Manager &mgr, + const SCFG::Hypothesis &hypo, int featureID, Scores &scores, + FFState &state) const; + +}; + +} + diff --git a/moses2/FF/ExampleStatelessFF.cpp b/moses2/FF/ExampleStatelessFF.cpp new file mode 100644 index 000000000..ab6260034 --- /dev/null +++ b/moses2/FF/ExampleStatelessFF.cpp @@ -0,0 +1,40 @@ +/* + * SkeletonStatefulFF.cpp + * + * Created on: 27 Oct 2015 + * Author: hieu + */ +#include "../Scores.h" + +#include "ExampleStatelessFF.h" + +namespace Moses2 +{ + +ExampleStatelessFF::ExampleStatelessFF(size_t startInd, + const std::string &line) : + StatelessFeatureFunction(startInd, line) +{ + ReadParameters(); +} + +ExampleStatelessFF::~ExampleStatelessFF() +{ + // TODO Auto-generated destructor stub +} + +void ExampleStatelessFF::EvaluateInIsolation(MemPool &pool, + const System &system, const Phrase &source, + const TargetPhraseImpl &targetPhrase, Scores &scores, + SCORE &estimatedScore) const +{ +} + +void ExampleStatelessFF::EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, + const TargetPhrase &targetPhrase, Scores &scores, + SCORE &estimatedScore) const +{ +} + +} + diff --git a/moses2/FF/ExampleStatelessFF.h b/moses2/FF/ExampleStatelessFF.h new file mode 100644 index 000000000..20b1acaaf --- /dev/null +++ b/moses2/FF/ExampleStatelessFF.h @@ -0,0 +1,34 @@ +/* + * SkeletonStatefulFF.h + * + * Created on: 27 Oct 2015 + * Author: hieu + */ + +#pragma once + +#include "StatelessFeatureFunction.h" + +namespace Moses2 +{ + +class ExampleStatelessFF: public StatelessFeatureFunction +{ +public: + ExampleStatelessFF(size_t startInd, const std::string &line); + virtual ~ExampleStatelessFF(); + + virtual void + EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, + const TargetPhraseImpl &targetPhrase, Scores &scores, + SCORE &estimatedScore) const; + + virtual void + EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, + const TargetPhrase &targetPhrase, Scores &scores, + SCORE &estimatedScore) const; + +}; + +} + diff --git a/moses2/FF/FeatureRegistry.cpp b/moses2/FF/FeatureRegistry.cpp index f7eae4205..3947d58c0 100644 --- a/moses2/FF/FeatureRegistry.cpp +++ b/moses2/FF/FeatureRegistry.cpp @@ -16,8 +16,8 @@ #include "WordPenalty.h" #include "OSM/OpSequenceModel.h" -#include "SkeletonStatefulFF.h" -#include "SkeletonStatelessFF.h" +#include "ExampleStatefulFF.h" +#include "ExampleStatelessFF.h" using namespace std; @@ -70,8 +70,8 @@ FeatureRegistry::FeatureRegistry() MOSES_FNAME(WordPenalty); MOSES_FNAME(OpSequenceModel); - MOSES_FNAME(SkeletonStatefulFF); - MOSES_FNAME(SkeletonStatelessFF); + MOSES_FNAME(ExampleStatefulFF); + MOSES_FNAME(ExampleStatelessFF); } FeatureRegistry::~FeatureRegistry() diff --git a/moses2/FF/SkeletonStatefulFF.cpp b/moses2/FF/SkeletonStatefulFF.cpp deleted file mode 100644 index c4c2b7329..000000000 --- a/moses2/FF/SkeletonStatefulFF.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * SkeletonStatefulFF.cpp - * - * Created on: 27 Oct 2015 - * Author: hieu - */ -#include -#include "SkeletonStatefulFF.h" -#include "../PhraseBased/Manager.h" -#include "../PhraseBased/Hypothesis.h" - -using namespace std; - -namespace Moses2 -{ - -class SkeletonState: public FFState -{ -public: - int targetLen; - - SkeletonState() { - // uninitialised - } - - virtual size_t hash() const { - return (size_t) targetLen; - } - virtual bool operator==(const FFState& o) const { - const SkeletonState& other = static_cast(o); - return targetLen == other.targetLen; - } - - virtual std::string ToString() const { - stringstream sb; - sb << targetLen; - return sb.str(); - } - -}; - -//////////////////////////////////////////////////////////////////////////////////////// -SkeletonStatefulFF::SkeletonStatefulFF(size_t startInd, const std::string &line) : - StatefulFeatureFunction(startInd, line) -{ - ReadParameters(); -} - -SkeletonStatefulFF::~SkeletonStatefulFF() -{ - // TODO Auto-generated destructor stub -} - -FFState* SkeletonStatefulFF::BlankState(MemPool &pool, const System &sys) const -{ - return new (pool.Allocate()) SkeletonState(); -} - -void SkeletonStatefulFF::EmptyHypothesisState(FFState &state, - const ManagerBase &mgr, const InputType &input, - const Hypothesis &hypo) const -{ - SkeletonState &stateCast = static_cast(state); - stateCast.targetLen = 0; -} - -void SkeletonStatefulFF::EvaluateInIsolation(MemPool &pool, - const System &system, const Phrase &source, - const TargetPhraseImpl &targetPhrase, Scores &scores, - SCORE &estimatedScore) const -{ -} - -void SkeletonStatefulFF::EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, - const TargetPhrase &targetPhrase, Scores &scores, - SCORE &estimatedScore) const -{ -} - -void SkeletonStatefulFF::EvaluateWhenApplied(const ManagerBase &mgr, - const Hypothesis &hypo, const FFState &prevState, Scores &scores, - FFState &state) const -{ - SkeletonState &stateCast = static_cast(state); - stateCast.targetLen = hypo.GetTargetPhrase().GetSize(); -} - -void SkeletonStatefulFF::EvaluateWhenApplied(const SCFG::Manager &mgr, - const SCFG::Hypothesis &hypo, int featureID, Scores &scores, - FFState &state) const -{ - UTIL_THROW2("Not implemented"); -} - -} - diff --git a/moses2/FF/SkeletonStatefulFF.h b/moses2/FF/SkeletonStatefulFF.h deleted file mode 100644 index 79256f2b3..000000000 --- a/moses2/FF/SkeletonStatefulFF.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SkeletonStatefulFF.h - * - * Created on: 27 Oct 2015 - * Author: hieu - */ - -#ifndef SKELETONSTATEFULFF_H_ -#define SKELETONSTATEFULFF_H_ - -#include "StatefulFeatureFunction.h" - -namespace Moses2 -{ - -class SkeletonStatefulFF: public StatefulFeatureFunction -{ -public: - SkeletonStatefulFF(size_t startInd, const std::string &line); - virtual ~SkeletonStatefulFF(); - - virtual FFState* BlankState(MemPool &pool, const System &sys) const; - virtual void EmptyHypothesisState(FFState &state, const ManagerBase &mgr, - const InputType &input, const Hypothesis &hypo) const; - - virtual void - EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, - const TargetPhraseImpl &targetPhrase, Scores &scores, - SCORE &estimatedScore) const; - - virtual void - EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, - const TargetPhrase &targetPhrase, Scores &scores, - SCORE &estimatedScore) const; - - virtual void EvaluateWhenApplied(const ManagerBase &mgr, - const Hypothesis &hypo, const FFState &prevState, Scores &scores, - FFState &state) const; - - virtual void EvaluateWhenApplied(const SCFG::Manager &mgr, - const SCFG::Hypothesis &hypo, int featureID, Scores &scores, - FFState &state) const; - -}; - -} - -#endif /* SKELETONSTATEFULFF_H_ */ diff --git a/moses2/FF/SkeletonStatelessFF.cpp b/moses2/FF/SkeletonStatelessFF.cpp deleted file mode 100644 index 4875f155d..000000000 --- a/moses2/FF/SkeletonStatelessFF.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SkeletonStatefulFF.cpp - * - * Created on: 27 Oct 2015 - * Author: hieu - */ -#include "../Scores.h" - -#include "SkeletonStatelessFF.h" - -namespace Moses2 -{ - -SkeletonStatelessFF::SkeletonStatelessFF(size_t startInd, - const std::string &line) : - StatelessFeatureFunction(startInd, line) -{ - ReadParameters(); -} - -SkeletonStatelessFF::~SkeletonStatelessFF() -{ - // TODO Auto-generated destructor stub -} - -void SkeletonStatelessFF::EvaluateInIsolation(MemPool &pool, - const System &system, const Phrase &source, - const TargetPhraseImpl &targetPhrase, Scores &scores, - SCORE &estimatedScore) const -{ -} - -void SkeletonStatelessFF::EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, - const TargetPhrase &targetPhrase, Scores &scores, - SCORE &estimatedScore) const -{ -} - -} - diff --git a/moses2/FF/SkeletonStatelessFF.h b/moses2/FF/SkeletonStatelessFF.h deleted file mode 100644 index f7e95005f..000000000 --- a/moses2/FF/SkeletonStatelessFF.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SkeletonStatefulFF.h - * - * Created on: 27 Oct 2015 - * Author: hieu - */ - -#pragma once - -#include "StatelessFeatureFunction.h" - -namespace Moses2 -{ - -class SkeletonStatelessFF: public StatelessFeatureFunction -{ -public: - SkeletonStatelessFF(size_t startInd, const std::string &line); - virtual ~SkeletonStatelessFF(); - - virtual void - EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, - const TargetPhraseImpl &targetPhrase, Scores &scores, - SCORE &estimatedScore) const; - - virtual void - EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, - const TargetPhrase &targetPhrase, Scores &scores, - SCORE &estimatedScore) const; - -}; - -} - diff --git a/moses2/Jamfile b/moses2/Jamfile index 886e81d8c..42676c065 100644 --- a/moses2/Jamfile +++ b/moses2/Jamfile @@ -47,8 +47,8 @@ alias deps : ..//z ..//boost_iostreams ..//boost_filesystem : : : $(max-factors FF/FeatureFunctions.cpp FF/FeatureRegistry.cpp FF/PhrasePenalty.cpp - FF/SkeletonStatefulFF.cpp - FF/SkeletonStatelessFF.cpp + FF/ExampleStatefulFF.cpp + FF/ExampleStatelessFF.cpp FF/StatefulFeatureFunction.cpp FF/StatelessFeatureFunction.cpp FF/WordPenalty.cpp -- cgit v1.2.3