Download tools/mosesdecoder/moses2/FF/ExampleStatefulFF.cpp from Quagmire1/wiki-cased: direct link, hf CLI and curl.
- Browser
- Download file 2.35 kB
-
https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/moses2/FF/ExampleStatefulFF.cpp
- Command line
-
hf download hf://Quagmire1/wiki-cased/tools/mosesdecoder/moses2/FF/ExampleStatefulFF.cpp
-
curl -L -o ExampleStatefulFF.cpp https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/moses2/FF/ExampleStatefulFF.cpp
2.35 kB
| /* | |
| * ExampleStatefulFF.cpp | |
| * | |
| * Created on: 27 Oct 2015 | |
| * Author: hieu | |
| */ | |
| 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<const ExampleState&>(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>()) ExampleState(); | |
| } | |
| void ExampleStatefulFF::EmptyHypothesisState(FFState &state, | |
| const ManagerBase &mgr, const InputType &input, | |
| const Hypothesis &hypo) const | |
| { | |
| ExampleState &stateCast = static_cast<ExampleState&>(state); | |
| stateCast.targetLen = 0; | |
| } | |
| void ExampleStatefulFF::EvaluateInIsolation(MemPool &pool, | |
| const System &system, const Phrase<Moses2::Word> &source, | |
| const TargetPhraseImpl &targetPhrase, Scores &scores, | |
| SCORE &estimatedScore) const | |
| { | |
| } | |
| void ExampleStatefulFF::EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<SCFG::Word> &source, | |
| const TargetPhrase<SCFG::Word> &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<ExampleState&>(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"); | |
| } | |
| } | |