Download tools/mosesdecoder/moses2/HypothesisBase.cpp from Quagmire1/wiki-cased: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/moses2/HypothesisBase.cpp
- Command line
-
hf download hf://Quagmire1/wiki-cased/tools/mosesdecoder/moses2/HypothesisBase.cpp
-
curl -L -o HypothesisBase.cpp https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/moses2/HypothesisBase.cpp
1.84 kB
| /* | |
| * Hypothesis.cpp | |
| * | |
| * Created on: 24 Oct 2015 | |
| * Author: hieu | |
| */ | |
| using namespace std; | |
| namespace Moses2 | |
| { | |
| //size_t g_numHypos = 0; | |
| HypothesisBase::HypothesisBase(MemPool &pool, const System &system) | |
| { | |
| m_scores = new (pool.Allocate<Scores>()) Scores(system, pool, | |
| system.featureFunctions.GetNumScores()); | |
| // FF states | |
| const std::vector<const StatefulFeatureFunction*> &sfffs = | |
| system.featureFunctions.GetStatefulFeatureFunctions(); | |
| size_t numStatefulFFs = sfffs.size(); | |
| m_ffStates = (FFState **) pool.Allocate(sizeof(FFState*) * numStatefulFFs); | |
| BOOST_FOREACH(const StatefulFeatureFunction *sfff, sfffs) { | |
| size_t statefulInd = sfff->GetStatefulInd(); | |
| FFState *state = sfff->BlankState(pool, system); | |
| m_ffStates[statefulInd] = state; | |
| } | |
| } | |
| size_t HypothesisBase::hash() const | |
| { | |
| return hash(0); | |
| } | |
| size_t HypothesisBase::hash(size_t seed) const | |
| { | |
| size_t numStatefulFFs = | |
| GetManager().system.featureFunctions.GetStatefulFeatureFunctions().size(); | |
| // states | |
| for (size_t i = 0; i < numStatefulFFs; ++i) { | |
| const FFState *state = m_ffStates[i]; | |
| size_t hash = state->hash(); | |
| boost::hash_combine(seed, hash); | |
| } | |
| return seed; | |
| } | |
| bool HypothesisBase::operator==(const HypothesisBase &other) const | |
| { | |
| size_t numStatefulFFs = | |
| GetManager().system.featureFunctions.GetStatefulFeatureFunctions().size(); | |
| // states | |
| for (size_t i = 0; i < numStatefulFFs; ++i) { | |
| const FFState &thisState = *m_ffStates[i]; | |
| const FFState &otherState = *other.m_ffStates[i]; | |
| if (thisState != otherState) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |
| } | |