diff options
author | redpony <redpony@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-08-01 01:14:50 +0400 |
---|---|---|
committer | redpony <redpony@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-08-01 01:14:50 +0400 |
commit | 472abe01a38ba313c7e362db8bb975d2a02ca00c (patch) | |
tree | 9e7c982fc3a0003e17a216c370fc0d0b45f717ac | |
parent | 540aadea2bff90a518c52ca0143ba603bb883b3d (diff) |
add score to set weights in the right position in the global score vector so things aren't so brittle
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@423 1f5c12ca-751b-0410-a591-d2e778427230
-rwxr-xr-x | moses/src/StaticData.cpp | 14 | ||||
-rwxr-xr-x | moses/src/StaticData.h | 8 |
2 files changed, 20 insertions, 2 deletions
diff --git a/moses/src/StaticData.cpp b/moses/src/StaticData.cpp index 6529c3155..3be2ee990 100755 --- a/moses/src/StaticData.cpp +++ b/moses/src/StaticData.cpp @@ -617,4 +617,16 @@ void StaticData::InitializeBeforeSentenceProcessing(InputType const& in) { for(size_t i=0;i<m_phraseDictionary.size();++i) m_phraseDictionary[i]->InitializeForInput(in); -}
\ No newline at end of file +} + +void StaticData::SetWeightsForScoreProducer(const ScoreProducer* sp, const std::vector<float>& weights) +{ + const size_t id = sp->GetScoreBookkeepingID(); + const size_t begin = m_scoreIndexManager.GetBeginIndex(id); + const size_t end = m_scoreIndexManager.GetEndIndex(id); + assert(end - begin == weights.size()); + std::vector<float>::const_iterator weightIter = weights.begin(); + for (size_t i = begin; i < end; i++) + m_allWeights[i] = *weightIter++; +} + diff --git a/moses/src/StaticData.h b/moses/src/StaticData.h index 04f467f2a..ac3ada6f7 100755 --- a/moses/src/StaticData.h +++ b/moses/src/StaticData.h @@ -99,6 +99,9 @@ protected: mutable SentenceStats m_sentenceStats; + //! Sets the global score vector weights for a given ScoreProducer. + void SetWeightsForScoreProducer(const ScoreProducer* sp, const std::vector<float>& weights); + public: StaticData(); ~StaticData(); @@ -222,8 +225,11 @@ public: { return m_languageModel[Initial].size() + m_languageModel[Other].size(); } + size_t GetNumLanguageModels() const + { + return GetLMSize(); + } const LMList GetAllLM() const; - size_t GetPhraseDictionarySize() const { return m_phraseDictionary.size(); |