From 75edc2edddd42a03a7f835672871b5de83825fae Mon Sep 17 00:00:00 2001 From: nicolabertoldi Date: Tue, 30 Aug 2011 12:25:50 +0000 Subject: [PATCH] change to print the corrett name of the features with InputScores git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4168 1f5c12ca-751b-0410-a591-d2e778427230 --- config.h.in | 3 - moses-chart-cmd/src/IOWrapper.cpp | 88 +++++++++-------------- moses-chart-cmd/src/Main.cpp | 2 +- moses-cmd/src/IOWrapper.cpp | 88 ++++++++--------------- moses-cmd/src/Main.cpp | 3 +- moses/src/DummyScoreProducers.cpp | 12 ++-- moses/src/DummyScoreProducers.h | 12 ++-- moses/src/GenerationDictionary.cpp | 8 ++- moses/src/GenerationDictionary.h | 6 +- moses/src/GlobalLexicalModel.h | 4 +- moses/src/LanguageModel.h | 6 +- moses/src/LanguageModelImplementation.h | 4 +- moses/src/LanguageModelMultiFactor.cpp | 2 +- moses/src/LanguageModelMultiFactor.h | 2 +- moses/src/LanguageModelSingleFactor.cpp | 2 +- moses/src/LanguageModelSingleFactor.h | 2 +- moses/src/LexicalReordering.h | 4 +- moses/src/PhraseDictionary.cpp | 17 ++++- moses/src/PhraseDictionary.h | 7 +- moses/src/PhraseDictionaryOnDisk.h | 2 +- moses/src/PhraseDictionarySCFG.h | 2 +- moses/src/PhraseDictionaryTree.cpp | 2 +- moses/src/PhraseDictionaryTree.h | 4 +- moses/src/PhraseDictionaryTreeAdaptor.cpp | 18 +++-- moses/src/PhraseDictionaryTreeAdaptor.h | 6 +- moses/src/ScoreIndexManager.cpp | 6 +- moses/src/ScoreProducer.h | 4 +- moses/src/SyntacticLanguageModel.cpp | 4 +- moses/src/SyntacticLanguageModel.h | 4 +- moses/src/TranslationSystem.cpp | 3 +- 30 files changed, 150 insertions(+), 177 deletions(-) diff --git a/config.h.in b/config.h.in index e3fbfc587..5d9d3fa8c 100644 --- a/config.h.in +++ b/config.h.in @@ -91,9 +91,6 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME -/* Define to the home page for this package. */ -#undef PACKAGE_URL - /* Define to the version of this package. */ #undef PACKAGE_VERSION diff --git a/moses-chart-cmd/src/IOWrapper.cpp b/moses-chart-cmd/src/IOWrapper.cpp index 48f9bd7ca..7f246205a 100644 --- a/moses-chart-cmd/src/IOWrapper.cpp +++ b/moses-chart-cmd/src/IOWrapper.cpp @@ -359,77 +359,55 @@ void IOWrapper::OutputNBestList(const ChartTrellisPathList &nBestList, const Cha } } + + std::string lastName = ""; + // translation components - if (StaticData::Instance().GetInputType()==SentenceInput) { - // translation components for text input - vector pds = system->GetPhraseDictionaries(); - if (pds.size() > 0) { - if (labeledOutput) - out << "tm: "; - vector::iterator iter; - for (iter = pds.begin(); iter != pds.end(); ++iter) { - vector scores = path.GetScoreBreakdown().GetScoresForProducer(*iter); - for (size_t j = 0; j pds = system->GetPhraseDictionaries(); - if (pds.size() > 0) { - vector::iterator iter; + const vector& pds = system->GetPhraseDictionaries(); + if (pds.size() > 0) { - iter = pds.begin(); - vector scores = path.GetScoreBreakdown().GetScoresForProducer(*iter); + for( size_t i=0; iGetNumInputScores(); + vector scores = path.GetScoreBreakdown().GetScoresForProducer( pds[i] ); + for (size_t j = 0; jGetNumInputScores(); - - if (pd_numinputscore) { - - if (labeledOutput) - out << "I: "; - - for (size_t j = 0; j < pd_numinputscore; ++j) - out << scores[j] << " "; - } - - - for (iter = pds.begin() ; iter != pds.end(); ++iter) { - vector scores = path.GetScoreBreakdown().GetScoresForProducer(*iter); - - size_t pd_numinputscore = (*iter)->GetNumInputScores(); - - if (iter == pds.begin() && labeledOutput) - out << "tm: "; - for (size_t j = pd_numinputscore; j < scores.size() ; ++j) - out << scores[j] << " "; - } + if (labeledOutput && (i == 0) ){ + if ((j == 0) || (j == pd_numinputscore)){ + lastName = pds[i]->GetScoreProducerWeightShortName(j); + out << " " << lastName << ":"; + } + } + out << " " << scores[j]; + } } } - - // word penalty if (labeledOutput) out << "w: "; out << path.GetScoreBreakdown().GetScoreForProducer(system->GetWordPenaltyProducer()) << " "; // generation - const vector gds = system->GetGenerationDictionaries(); + const vector& gds = system->GetGenerationDictionaries(); if (gds.size() > 0) { - if (labeledOutput) - out << "g: "; - vector::const_iterator iter; - for (iter = gds.begin(); iter != gds.end(); ++iter) { - vector scores = path.GetScoreBreakdown().GetScoresForProducer(*iter); - for (size_t j = 0; jGetNumInputScores(); + vector scores = path.GetScoreBreakdown().GetScoresForProducer( gds[i] ); + for (size_t j = 0; jGetScoreProducerWeightShortName(j); + out << " " << lastName << ":"; + } + } + out << " " << scores[j]; + } } } + // total out << "||| " << path.GetTotalScore(); diff --git a/moses-chart-cmd/src/Main.cpp b/moses-chart-cmd/src/Main.cpp index f86b128e9..7032bf849 100644 --- a/moses-chart-cmd/src/Main.cpp +++ b/moses-chart-cmd/src/Main.cpp @@ -170,7 +170,7 @@ static void PrintFeatureWeight(const FeatureFunction* ff) size_t weightStart = StaticData::Instance().GetScoreIndexManager().GetBeginIndex(ff->GetScoreBookkeepingID()); size_t weightEnd = StaticData::Instance().GetScoreIndexManager().GetEndIndex(ff->GetScoreBookkeepingID()); for (size_t i = weightStart; i < weightEnd; ++i) { - cout << ff->GetScoreProducerDescription() << " " << ff->GetScoreProducerWeightShortName() << " " + cout << ff->GetScoreProducerDescription(i-weightStart) << " " << ff->GetScoreProducerWeightShortName(i-weightStart) << " " << StaticData::Instance().GetAllWeights()[i] << endl; } } diff --git a/moses-cmd/src/IOWrapper.cpp b/moses-cmd/src/IOWrapper.cpp index abf569ca9..5dac23560 100755 --- a/moses-cmd/src/IOWrapper.cpp +++ b/moses-cmd/src/IOWrapper.cpp @@ -383,8 +383,7 @@ void OutputNBest(std::ostream& out, const Moses::TrellisPathList &nBestList, con out << " |||"; std::string lastName = ""; - const vector& sff = - system->GetStatefulFeatureFunctions(); + const vector& sff = system->GetStatefulFeatureFunctions(); for( size_t i=0; iGetScoreProducerWeightShortName() ) { lastName = sff[i]->GetScoreProducerWeightShortName(); @@ -396,8 +395,7 @@ void OutputNBest(std::ostream& out, const Moses::TrellisPathList &nBestList, con } } - const vector& slf = - system->GetStatelessFeatureFunctions(); + const vector& slf = system->GetStatelessFeatureFunctions(); for( size_t i=0; iGetScoreProducerWeightShortName() ) { lastName = slf[i]->GetScoreProducerWeightShortName(); @@ -410,66 +408,42 @@ void OutputNBest(std::ostream& out, const Moses::TrellisPathList &nBestList, con } // translation components - if (StaticData::Instance().GetInputType()==SentenceInput) { - // translation components for text input - vector pds = system->GetPhraseDictionaries(); - if (pds.size() > 0) { - if (labeledOutput) - out << " tm:"; - vector::iterator iter; - for (iter = pds.begin(); iter != pds.end(); ++iter) { - vector scores = path.GetScoreBreakdown().GetScoresForProducer(*iter); - for (size_t j = 0; j pds = system->GetPhraseDictionaries(); - if (pds.size() > 0) { - vector::iterator iter; + const vector& pds = system->GetPhraseDictionaries(); + if (pds.size() > 0) { - iter = pds.begin(); - vector scores = path.GetScoreBreakdown().GetScoresForProducer(*iter); + for( size_t i=0; iGetNumInputScores(); + vector scores = path.GetScoreBreakdown().GetScoresForProducer( pds[i] ); + for (size_t j = 0; jGetNumInputScores(); - - if (pd_numinputscore) { - - if (labeledOutput) - out << " I:"; - - for (size_t j = 0; j < pd_numinputscore; ++j) - out << " " << scores[j]; - } - - - for (iter = pds.begin() ; iter != pds.end(); ++iter) { - vector scores = path.GetScoreBreakdown().GetScoresForProducer(*iter); - - size_t pd_numinputscore = (*iter)->GetNumInputScores(); - - if (iter == pds.begin() && labeledOutput) - out << " tm:"; - for (size_t j = pd_numinputscore; j < scores.size() ; ++j) - out << " " << scores[j]; - } + if (labeledOutput && (i == 0) ){ + if ((j == 0) || (j == pd_numinputscore)){ + lastName = pds[i]->GetScoreProducerWeightShortName(j); + out << " " << lastName << ":"; + } + } + out << " " << scores[j]; + } } } // generation - const vector gds = system->GetGenerationDictionaries(); + const vector& gds = system->GetGenerationDictionaries(); if (gds.size() > 0) { - if (labeledOutput) - out << " g: "; - vector::const_iterator iter; - for (iter = gds.begin(); iter != gds.end(); ++iter) { - vector scores = path.GetScoreBreakdown().GetScoresForProducer(*iter); - for (size_t j = 0; jGetNumInputScores(); + vector scores = path.GetScoreBreakdown().GetScoresForProducer( gds[i] ); + for (size_t j = 0; jGetScoreProducerWeightShortName(j); + out << " " << lastName << ":"; + } + } + out << " " << scores[j]; + } } } diff --git a/moses-cmd/src/Main.cpp b/moses-cmd/src/Main.cpp index 3720f4256..69fd9c797 100644 --- a/moses-cmd/src/Main.cpp +++ b/moses-cmd/src/Main.cpp @@ -279,7 +279,7 @@ static void PrintFeatureWeight(const FeatureFunction* ff) size_t weightStart = StaticData::Instance().GetScoreIndexManager().GetBeginIndex(ff->GetScoreBookkeepingID()); size_t weightEnd = StaticData::Instance().GetScoreIndexManager().GetEndIndex(ff->GetScoreBookkeepingID()); for (size_t i = weightStart; i < weightEnd; ++i) { - cout << ff->GetScoreProducerDescription() << " " << ff->GetScoreProducerWeightShortName() << " " + cout << ff->GetScoreProducerDescription(i-weightStart) << " " << ff->GetScoreProducerWeightShortName(i-weightStart) << " " << StaticData::Instance().GetAllWeights()[i] << endl; } } @@ -335,6 +335,7 @@ int main(int argc, char** argv) exit(1); } + // create threadpool, if using multi-threaded decoding // note: multi-threading is done on sentence-level, // each thread translates one sentence diff --git a/moses/src/DummyScoreProducers.cpp b/moses/src/DummyScoreProducers.cpp index d41b67f02..958d3df5a 100644 --- a/moses/src/DummyScoreProducers.cpp +++ b/moses/src/DummyScoreProducers.cpp @@ -48,12 +48,12 @@ size_t DistortionScoreProducer::GetNumScoreComponents() const return 1; } -std::string DistortionScoreProducer::GetScoreProducerDescription() const +std::string DistortionScoreProducer::GetScoreProducerDescription(unsigned) const { return "Distortion"; } -std::string DistortionScoreProducer::GetScoreProducerWeightShortName() const +std::string DistortionScoreProducer::GetScoreProducerWeightShortName(unsigned) const { return "d"; } @@ -119,12 +119,12 @@ size_t WordPenaltyProducer::GetNumScoreComponents() const return 1; } -std::string WordPenaltyProducer::GetScoreProducerDescription() const +std::string WordPenaltyProducer::GetScoreProducerDescription(unsigned) const { return "WordPenalty"; } -std::string WordPenaltyProducer::GetScoreProducerWeightShortName() const +std::string WordPenaltyProducer::GetScoreProducerWeightShortName(unsigned) const { return "w"; } @@ -149,12 +149,12 @@ size_t UnknownWordPenaltyProducer::GetNumScoreComponents() const return 1; } -std::string UnknownWordPenaltyProducer::GetScoreProducerDescription() const +std::string UnknownWordPenaltyProducer::GetScoreProducerDescription(unsigned) const { return "!UnknownWordPenalty"; } -std::string UnknownWordPenaltyProducer::GetScoreProducerWeightShortName() const +std::string UnknownWordPenaltyProducer::GetScoreProducerWeightShortName(unsigned) const { return "u"; } diff --git a/moses/src/DummyScoreProducers.h b/moses/src/DummyScoreProducers.h index 56fe26545..c3876fa30 100644 --- a/moses/src/DummyScoreProducers.h +++ b/moses/src/DummyScoreProducers.h @@ -21,8 +21,8 @@ public: const WordsRange &prev, const WordsRange &curr, const int FirstGapPosition) const; size_t GetNumScoreComponents() const; - std::string GetScoreProducerDescription() const; - std::string GetScoreProducerWeightShortName() const; + std::string GetScoreProducerDescription(unsigned) const; + std::string GetScoreProducerWeightShortName(unsigned) const; size_t GetNumInputScores() const; virtual const FFState* EmptyHypothesisState(const InputType &input) const; @@ -50,8 +50,8 @@ public: WordPenaltyProducer(ScoreIndexManager &scoreIndexManager); size_t GetNumScoreComponents() const; - std::string GetScoreProducerDescription() const; - std::string GetScoreProducerWeightShortName() const; + std::string GetScoreProducerDescription(unsigned) const; + std::string GetScoreProducerWeightShortName(unsigned) const; size_t GetNumInputScores() const; virtual void Evaluate( @@ -66,8 +66,8 @@ public: UnknownWordPenaltyProducer(ScoreIndexManager &scoreIndexManager); size_t GetNumScoreComponents() const; - std::string GetScoreProducerDescription() const; - std::string GetScoreProducerWeightShortName() const; + std::string GetScoreProducerDescription(unsigned) const; + std::string GetScoreProducerWeightShortName(unsigned) const; size_t GetNumInputScores() const; virtual bool ComputeValueInTranslationOption() const; diff --git a/moses/src/GenerationDictionary.cpp b/moses/src/GenerationDictionary.cpp index d9d8191d9..fedd04886 100644 --- a/moses/src/GenerationDictionary.cpp +++ b/moses/src/GenerationDictionary.cpp @@ -123,11 +123,17 @@ size_t GenerationDictionary::GetNumScoreComponents() const return m_numScoreComponent; } -std::string GenerationDictionary::GetScoreProducerDescription() const +std::string GenerationDictionary::GetScoreProducerDescription(unsigned) const { return "Generation score, file=" + m_filePath; } +std::string GenerationDictionary::GetScoreProducerWeightShortName(unsigned) const +{ + return "g"; +} + + const OutputWordCollection *GenerationDictionary::FindWord(const Word &word) const { const OutputWordCollection *ret; diff --git a/moses/src/GenerationDictionary.h b/moses/src/GenerationDictionary.h index f20b4d3d6..a666ae4af 100644 --- a/moses/src/GenerationDictionary.h +++ b/moses/src/GenerationDictionary.h @@ -71,10 +71,8 @@ public: bool Load(const std::string &filePath, FactorDirection direction); size_t GetNumScoreComponents() const; - std::string GetScoreProducerDescription() const; - std::string GetScoreProducerWeightShortName() const { - return "g"; - } + std::string GetScoreProducerDescription(unsigned) const; + std::string GetScoreProducerWeightShortName(unsigned) const; /** number of unique input entries in the generation table. * NOT the number of lines in the generation table diff --git a/moses/src/GlobalLexicalModel.h b/moses/src/GlobalLexicalModel.h index c033fceac..f22f5430a 100644 --- a/moses/src/GlobalLexicalModel.h +++ b/moses/src/GlobalLexicalModel.h @@ -58,11 +58,11 @@ public: return 1; }; - virtual std::string GetScoreProducerDescription() const { + virtual std::string GetScoreProducerDescription(unsigned) const { return "GlobalLexicalModel"; }; - virtual std::string GetScoreProducerWeightShortName() const { + virtual std::string GetScoreProducerWeightShortName(unsigned) const { return "lex"; }; diff --git a/moses/src/LanguageModel.h b/moses/src/LanguageModel.h index 92b31b0e2..198ebf659 100644 --- a/moses/src/LanguageModel.h +++ b/moses/src/LanguageModel.h @@ -95,13 +95,13 @@ public: return m_implementation->GetNGramOrder(); } - virtual std::string GetScoreProducerDescription() const { - return m_implementation->GetScoreProducerDescription(); + virtual std::string GetScoreProducerDescription(unsigned idx=0) const { + return m_implementation->GetScoreProducerDescription(idx); } float GetWeight() const; - std::string GetScoreProducerWeightShortName() const { + std::string GetScoreProducerWeightShortName(unsigned) const { return "lm"; } diff --git a/moses/src/LanguageModelImplementation.h b/moses/src/LanguageModelImplementation.h index 954ba1de6..628d05b21 100644 --- a/moses/src/LanguageModelImplementation.h +++ b/moses/src/LanguageModelImplementation.h @@ -109,11 +109,11 @@ public: return m_sentenceEndArray; } - virtual std::string GetScoreProducerDescription() const = 0; + virtual std::string GetScoreProducerDescription(unsigned) const = 0; float GetWeight() const; - std::string GetScoreProducerWeightShortName() const { + std::string GetScoreProducerWeightShortName(unsigned) const { return "lm"; } diff --git a/moses/src/LanguageModelMultiFactor.cpp b/moses/src/LanguageModelMultiFactor.cpp index a2c4ba777..67474b641 100644 --- a/moses/src/LanguageModelMultiFactor.cpp +++ b/moses/src/LanguageModelMultiFactor.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA namespace Moses { -std::string LanguageModelMultiFactor::GetScoreProducerDescription() const +std::string LanguageModelMultiFactor::GetScoreProducerDescription(unsigned) const { std::ostringstream oss; // what about LMs that are over multiple factors at once, POS + stem, for example? diff --git a/moses/src/LanguageModelMultiFactor.h b/moses/src/LanguageModelMultiFactor.h index 9ddb07448..4225f4a3a 100644 --- a/moses/src/LanguageModelMultiFactor.h +++ b/moses/src/LanguageModelMultiFactor.h @@ -48,7 +48,7 @@ public: return MultiFactor; } - std::string GetScoreProducerDescription() const; + std::string GetScoreProducerDescription(unsigned) const; bool Useable(const Phrase &phrase) const; }; diff --git a/moses/src/LanguageModelSingleFactor.cpp b/moses/src/LanguageModelSingleFactor.cpp index be4d79912..026d76030 100644 --- a/moses/src/LanguageModelSingleFactor.cpp +++ b/moses/src/LanguageModelSingleFactor.cpp @@ -40,7 +40,7 @@ namespace Moses LanguageModelSingleFactor::~LanguageModelSingleFactor() {} -std::string LanguageModelSingleFactor::GetScoreProducerDescription() const +std::string LanguageModelSingleFactor::GetScoreProducerDescription(unsigned) const { std::ostringstream oss; // what about LMs that are over multiple factors at once, POS + stem, for example? diff --git a/moses/src/LanguageModelSingleFactor.h b/moses/src/LanguageModelSingleFactor.h index 7282277ae..f236a3d4d 100644 --- a/moses/src/LanguageModelSingleFactor.h +++ b/moses/src/LanguageModelSingleFactor.h @@ -61,7 +61,7 @@ public: FactorType GetFactorType() const { return m_factorType; } - std::string GetScoreProducerDescription() const; + std::string GetScoreProducerDescription(unsigned) const; }; // Single factor LM that uses a null pointer state. diff --git a/moses/src/LexicalReordering.h b/moses/src/LexicalReordering.h index b8ce66b5e..61865f78c 100644 --- a/moses/src/LexicalReordering.h +++ b/moses/src/LexicalReordering.h @@ -49,11 +49,11 @@ public: virtual const FFState* EmptyHypothesisState(const InputType &input) const; - virtual std::string GetScoreProducerDescription() const { + virtual std::string GetScoreProducerDescription(unsigned) const { return "LexicalReordering_" + m_modelTypeString; } - std::string GetScoreProducerWeightShortName() const { + std::string GetScoreProducerWeightShortName(unsigned) const { return "d"; }; diff --git a/moses/src/PhraseDictionary.cpp b/moses/src/PhraseDictionary.cpp index 8d185bab6..589b07f45 100644 --- a/moses/src/PhraseDictionary.cpp +++ b/moses/src/PhraseDictionary.cpp @@ -214,9 +214,22 @@ PhraseDictionaryFeature::~PhraseDictionaryFeature() {} -std::string PhraseDictionaryFeature::GetScoreProducerDescription() const +std::string PhraseDictionaryFeature::GetScoreProducerDescription(unsigned idx) const { - return "PhraseModel"; + if (idx < GetNumInputScores()){ + return "InputScore"; + }else{ + return "PhraseModel"; + } +} + +std::string PhraseDictionaryFeature::GetScoreProducerWeightShortName(unsigned idx) const +{ + if (idx < GetNumInputScores()){ + return "I"; + }else{ + return "tm"; + } } size_t PhraseDictionaryFeature::GetNumScoreComponents() const diff --git a/moses/src/PhraseDictionary.h b/moses/src/PhraseDictionary.h index ede31a52c..e8d6ca4cf 100644 --- a/moses/src/PhraseDictionary.h +++ b/moses/src/PhraseDictionary.h @@ -112,10 +112,9 @@ public: virtual bool ComputeValueInTranslationOption() const; - std::string GetScoreProducerDescription() const; - std::string GetScoreProducerWeightShortName() const { - return "tm"; - } + std::string GetScoreProducerDescription(unsigned) const; + std::string GetScoreProducerWeightShortName(unsigned idx=0) const; + size_t GetNumScoreComponents() const; size_t GetNumInputScores() const; diff --git a/moses/src/PhraseDictionaryOnDisk.h b/moses/src/PhraseDictionaryOnDisk.h index fa3a6fe85..44192dfdf 100644 --- a/moses/src/PhraseDictionaryOnDisk.h +++ b/moses/src/PhraseDictionaryOnDisk.h @@ -68,7 +68,7 @@ public: const LMList& languageModels, const WordPenaltyProducer* wpProducer); - std::string GetScoreProducerDescription() const { + std::string GetScoreProducerDescription(unsigned) const { return "BerkeleyPt"; } diff --git a/moses/src/PhraseDictionarySCFG.h b/moses/src/PhraseDictionarySCFG.h index dd79289c3..3fa109c3a 100644 --- a/moses/src/PhraseDictionarySCFG.h +++ b/moses/src/PhraseDictionarySCFG.h @@ -66,7 +66,7 @@ public: } virtual ~PhraseDictionarySCFG(); - std::string GetScoreProducerDescription() const { + std::string GetScoreProducerDescription(unsigned) const { return "Hieu's Reordering Model"; } diff --git a/moses/src/PhraseDictionaryTree.cpp b/moses/src/PhraseDictionaryTree.cpp index 634ffa967..bc0874d15 100644 --- a/moses/src/PhraseDictionaryTree.cpp +++ b/moses/src/PhraseDictionaryTree.cpp @@ -661,7 +661,7 @@ GetTargetCandidates(PrefixPtr p, imp->ConvertTgtCand(tcands,rv,wa); } -std::string PhraseDictionaryTree::GetScoreProducerDescription() const +std::string PhraseDictionaryTree::GetScoreProducerDescription(unsigned) const { return "PhraseDictionaryTree"; } diff --git a/moses/src/PhraseDictionaryTree.h b/moses/src/PhraseDictionaryTree.h index 551964b0f..543aaebed 100644 --- a/moses/src/PhraseDictionaryTree.h +++ b/moses/src/PhraseDictionaryTree.h @@ -122,8 +122,8 @@ public: // print target candidates for a given prefix pointer to a stream, mainly // for debugging void PrintTargetCandidates(PrefixPtr p,std::ostream& out) const; - std::string GetScoreProducerDescription() const; - std::string GetScoreProducerWeightShortName() const { + std::string GetScoreProducerDescription(unsigned) const; + std::string GetScoreProducerWeightShortName(unsigned) const { return "tm"; } }; diff --git a/moses/src/PhraseDictionaryTreeAdaptor.cpp b/moses/src/PhraseDictionaryTreeAdaptor.cpp index 4205abdb1..aa90bde81 100644 --- a/moses/src/PhraseDictionaryTreeAdaptor.cpp +++ b/moses/src/PhraseDictionaryTreeAdaptor.cpp @@ -105,11 +105,21 @@ size_t PhraseDictionaryTreeAdaptor::GetNumInputScores() const return imp->GetNumInputScores(); } -std::string PhraseDictionaryTreeAdaptor::GetScoreProducerDescription() const +std::string PhraseDictionaryTreeAdaptor::GetScoreProducerDescription(unsigned idx) const{ + if (idx < imp->GetNumInputScores()){ + return "InputScore"; + }else{ + return "PhraseModel"; + } +} + +std::string PhraseDictionaryTreeAdaptor::GetScoreProducerWeightShortName(unsigned idx) const { - return "PhraseModel"; + if (idx < imp->GetNumInputScores()){ + return "I"; + }else{ + return "tm"; + } } } - - diff --git a/moses/src/PhraseDictionaryTreeAdaptor.h b/moses/src/PhraseDictionaryTreeAdaptor.h index 9f4567eb2..5e834acb3 100644 --- a/moses/src/PhraseDictionaryTreeAdaptor.h +++ b/moses/src/PhraseDictionaryTreeAdaptor.h @@ -60,10 +60,8 @@ public: // this function can be only used for UNKNOWN source phrases void AddEquivPhrase(const Phrase &source, const TargetPhrase &targetPhrase); - std::string GetScoreProducerDescription() const; - std::string GetScoreProducerWeightShortName() const { - return "tm"; - } + std::string GetScoreProducerDescription(unsigned idx=0) const; + std::string GetScoreProducerWeightShortName(unsigned idx=0) const; size_t GetNumInputScores() const; virtual void InitializeForInput(InputType const& source); diff --git a/moses/src/ScoreIndexManager.cpp b/moses/src/ScoreIndexManager.cpp index e7fa2e199..c3d375468 100644 --- a/moses/src/ScoreIndexManager.cpp +++ b/moses/src/ScoreIndexManager.cpp @@ -67,7 +67,7 @@ void ScoreIndexManager::InitFeatureNames() bool add_idx = (m_producers[cur_scoreType]->GetNumInputScores() > 1); while (nis_idx < m_producers[cur_scoreType]->GetNumInputScores()) { ostringstream os; - os << m_producers[cur_scoreType]->GetScoreProducerDescription(); + os << m_producers[cur_scoreType]->GetScoreProducerDescription(nis_idx); if (add_idx) os << '_' << (nis_idx+1); m_featureNames.push_back(os.str()); @@ -79,11 +79,11 @@ void ScoreIndexManager::InitFeatureNames() add_idx = (m_ends[cur_scoreType] - cur_i > 1); while (cur_i < m_ends[cur_scoreType]) { ostringstream os; - os << m_producers[cur_scoreType]->GetScoreProducerDescription(); + os << m_producers[cur_scoreType]->GetScoreProducerDescription(nis_idx+ind-1); if (add_idx) os << '_' << ind; m_featureNames.push_back(os.str()); - m_featureShortNames.push_back( m_producers[cur_scoreType]->GetScoreProducerWeightShortName() ); + m_featureShortNames.push_back( m_producers[cur_scoreType]->GetScoreProducerWeightShortName(nis_idx+ind-1) ); ++cur_i; ++ind; } diff --git a/moses/src/ScoreProducer.h b/moses/src/ScoreProducer.h index 79e749a1e..0065b774a 100644 --- a/moses/src/ScoreProducer.h +++ b/moses/src/ScoreProducer.h @@ -50,10 +50,10 @@ public: virtual size_t GetNumScoreComponents() const = 0; //! returns a string description of this producer - virtual std::string GetScoreProducerDescription() const = 0; + virtual std::string GetScoreProducerDescription(unsigned idx=0) const = 0; //! returns the weight parameter name of this producer (used in n-best list) - virtual std::string GetScoreProducerWeightShortName() const = 0; + virtual std::string GetScoreProducerWeightShortName(unsigned idx=0) const = 0; //! returns the number of scores gathered from the input (0 by default) virtual size_t GetNumInputScores() const { diff --git a/moses/src/SyntacticLanguageModel.cpp b/moses/src/SyntacticLanguageModel.cpp index 85c19bdc0..c9b3f1e22 100755 --- a/moses/src/SyntacticLanguageModel.cpp +++ b/moses/src/SyntacticLanguageModel.cpp @@ -36,11 +36,11 @@ namespace Moses return m_NumScoreComponents; } - std::string SyntacticLanguageModel::GetScoreProducerDescription() const { + std::string SyntacticLanguageModel::GetScoreProducerDescription(unsigned) const { return "Syntactic Language Model"; } - std::string SyntacticLanguageModel::GetScoreProducerWeightShortName() const { + std::string SyntacticLanguageModel::GetScoreProducerWeightShortName(unsigned) const { return "slm"; } diff --git a/moses/src/SyntacticLanguageModel.h b/moses/src/SyntacticLanguageModel.h index 977a57680..3497d3dc4 100755 --- a/moses/src/SyntacticLanguageModel.h +++ b/moses/src/SyntacticLanguageModel.h @@ -26,8 +26,8 @@ namespace Moses ~SyntacticLanguageModel(); size_t GetNumScoreComponents() const; - std::string GetScoreProducerDescription() const; - std::string GetScoreProducerWeightShortName() const; + std::string GetScoreProducerDescription(unsigned) const; + std::string GetScoreProducerWeightShortName(unsigned) const; const FFState* EmptyHypothesisState(const InputType &input) const; diff --git a/moses/src/TranslationSystem.cpp b/moses/src/TranslationSystem.cpp index 328a2ba4d..8d51e79a6 100644 --- a/moses/src/TranslationSystem.cpp +++ b/moses/src/TranslationSystem.cpp @@ -96,8 +96,7 @@ void TranslationSystem::AddFeatureFunction(const FeatureFunction* ff) void TranslationSystem::ConfigDictionaries() { - for (vector::const_iterator i = m_decodeGraphs.begin(); - i != m_decodeGraphs.end(); ++i) { + for (vector::const_iterator i = m_decodeGraphs.begin(); i != m_decodeGraphs.end(); ++i) { for (DecodeGraph::const_iterator j = (*i)->begin(); j != (*i)->end(); ++j) { const DecodeStep* step = *j; PhraseDictionaryFeature* pdict = const_cast(step->GetPhraseDictionaryFeature());