diff --git a/moses/src/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp b/moses/src/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp index 0398eed28..0cf3c836b 100644 --- a/moses/src/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp +++ b/moses/src/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp @@ -236,7 +236,7 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection( const OnDiskPt::TargetPhraseCollection *tpcollBerkeleyDb = node->GetTargetPhraseCollection(m_dictionary.GetTableLimit(), m_dbWrapper); - std::vector weightT = staticData.GetTranslationSystem(TranslationSystem::DEFAULT).GetTranslationWeights(m_dictionary.GetDictIndex()); + std::vector weightT = staticData.GetWeights(m_dictionary.GetFeature()); targetPhraseCollection = tpcollBerkeleyDb->ConvertToMoses(m_inputFactorsVec ,m_outputFactorsVec diff --git a/moses/src/PDTAimp.h b/moses/src/PDTAimp.h index 79e929601..2d2b6974c 100644 --- a/moses/src/PDTAimp.h +++ b/moses/src/PDTAimp.h @@ -139,8 +139,9 @@ protected: return 0; } + //TODO: Multiple models broken here const TranslationSystem& system = StaticData::Instance().GetTranslationSystem(TranslationSystem::DEFAULT); - std::vector weights = system.GetTranslationWeights(m_obj->GetDictIndex()); + std::vector weights = StaticData::Instance().GetWeights(m_obj->GetFeature()); float weightWP = system.GetWeightWordPenalty(); std::vector tCands; @@ -374,7 +375,7 @@ protected: stack.push_back(State(i, i, m_dict->GetRoot(), std::vector(m_numInputScores,0.0))); const TranslationSystem& system = StaticData::Instance().GetTranslationSystem(TranslationSystem::DEFAULT); - std::vector weightT = system.GetTranslationWeights(m_obj->GetDictIndex()); + std::vector weightT = StaticData::Instance().GetWeights(m_obj->GetFeature()); float weightWP = system.GetWeightWordPenalty(); while(!stack.empty()) { diff --git a/moses/src/PhraseDictionary.cpp b/moses/src/PhraseDictionary.cpp index 77e02dab6..766366134 100644 --- a/moses/src/PhraseDictionary.cpp +++ b/moses/src/PhraseDictionary.cpp @@ -87,7 +87,7 @@ PhraseDictionaryFeature::PhraseDictionaryFeature PhraseDictionary* PhraseDictionaryFeature::LoadPhraseTable(const TranslationSystem* system) { const StaticData& staticData = StaticData::Instance(); - std::vector weightT = system->GetTranslationWeights(m_dictIndex); + std::vector weightT = staticData.GetWeights(this); if (m_implementation == Memory) { // memory phrase table diff --git a/moses/src/RuleTable/PhraseDictionaryALSuffixArray.cpp b/moses/src/RuleTable/PhraseDictionaryALSuffixArray.cpp index 8218c5bc4..21acbcab0 100644 --- a/moses/src/RuleTable/PhraseDictionaryALSuffixArray.cpp +++ b/moses/src/RuleTable/PhraseDictionaryALSuffixArray.cpp @@ -64,7 +64,7 @@ void PhraseDictionaryALSuffixArray::InitializeForInput(InputType const& source) std::auto_ptr loader = RuleTableLoaderFactory::Create(grammarFile); - std::vector weightT = StaticData::Instance().GetTranslationSystem(TranslationSystem::DEFAULT).GetTranslationWeights(GetDictIndex()); + std::vector weightT = StaticData::Instance().GetWeights(GetFeature()); bool ret = loader->Load(*m_input, *m_output, inFile, weightT, m_tableLimit, *m_languageModels, m_wpProducer, *this); diff --git a/moses/src/RuleTable/PhraseDictionaryOnDisk.cpp b/moses/src/RuleTable/PhraseDictionaryOnDisk.cpp index 908f93e74..c0c97b2fc 100644 --- a/moses/src/RuleTable/PhraseDictionaryOnDisk.cpp +++ b/moses/src/RuleTable/PhraseDictionaryOnDisk.cpp @@ -91,7 +91,6 @@ ChartRuleLookupManager *PhraseDictionaryOnDisk::CreateRuleLookupManager( const InputType &sentence, const ChartCellCollection &cellCollection) { - std::vector weightT = StaticData::Instance().GetTranslationSystem(TranslationSystem::DEFAULT).GetTranslationWeights(GetDictIndex()); return new ChartRuleLookupManagerOnDisk(sentence, cellCollection, *this, m_dbWrapper, m_languageModels, m_wpProducer, m_inputFactorsVec, diff --git a/moses/src/ScoreComponentCollection.h b/moses/src/ScoreComponentCollection.h index e170d0cd9..f2bd73d6b 100644 --- a/moses/src/ScoreComponentCollection.h +++ b/moses/src/ScoreComponentCollection.h @@ -73,7 +73,13 @@ private: static IndexPair GetIndexes(const ScoreProducer* sp) { ScoreIndexMap::const_iterator indexIter = s_scoreIndexes.find(sp); - CHECK(indexIter != s_scoreIndexes.end()); + if (indexIter == s_scoreIndexes.end()) { + std::cerr << "ERROR: ScoreProducer: " << sp->GetScoreProducerDescription() << + " not registered with ScoreIndexMap" << std::endl; + std::cerr << "You must call ScoreComponentCollection.RegisterScoreProducer() " << + " for every ScoreProducer" << std::endl; + abort(); + } return indexIter->second; } diff --git a/moses/src/TranslationSystem.cpp b/moses/src/TranslationSystem.cpp index e017ba241..c21b5ed8f 100644 --- a/moses/src/TranslationSystem.cpp +++ b/moses/src/TranslationSystem.cpp @@ -175,12 +175,4 @@ namespace Moses { return StaticData::Instance().GetWeight(m_distortionScoreProducer); } - std::vector TranslationSystem::GetTranslationWeights(size_t index) const { - std::vector weights = StaticData::Instance().GetWeights(GetTranslationScoreProducer(index)); - //VERBOSE(1, "Read weightT from translation sytem.. "); - for (size_t i = 0; i < weights.size(); ++i) - //VERBOSE(1, weights[i] << " "); - //VERBOSE(1, std::endl); - return weights; - } }; diff --git a/moses/src/TranslationSystem.h b/moses/src/TranslationSystem.h index 6f66fd25a..f40ef084c 100644 --- a/moses/src/TranslationSystem.h +++ b/moses/src/TranslationSystem.h @@ -83,12 +83,11 @@ class TranslationSystem { const UnknownWordPenaltyProducer *GetUnknownWordPenaltyProducer() const { return m_unknownWpProducer; } const DistortionScoreProducer* GetDistortionProducer() const {return m_distortionScoreProducer;} - const PhraseDictionaryFeature *GetTranslationScoreProducer(size_t index) const { return GetPhraseDictionaries()[index]; } + const PhraseDictionaryFeature *GetTranslationScoreProducer(size_t index) const { return GetPhraseDictionaries().at(index); } float GetWeightWordPenalty() const; float GetWeightUnknownWordPenalty() const; float GetWeightDistortion() const; - std::vector GetTranslationWeights(size_t index) const; //sentence (and thread) specific initialisationn and cleanup void InitializeBeforeSentenceProcessing(const InputType& source) const;