diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2014-12-30 16:23:30 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2014-12-30 16:23:30 +0300 |
commit | ba166f109cc1bda482e32ba490905d769dc1b9ae (patch) | |
tree | 07741cdfbdb178f2dace9cdfba125c369d0cba55 /moses/ScoreComponentCollection.cpp | |
parent | 14cbf9bc2263485a5bef03fd61632a3fda41af6c (diff) |
moving more stuff out of IOWrapper
Diffstat (limited to 'moses/ScoreComponentCollection.cpp')
-rw-r--r-- | moses/ScoreComponentCollection.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/moses/ScoreComponentCollection.cpp b/moses/ScoreComponentCollection.cpp index eedaa589e..2903b112c 100644 --- a/moses/ScoreComponentCollection.cpp +++ b/moses/ScoreComponentCollection.cpp @@ -3,6 +3,8 @@ #include "util/exception.hh" #include "ScoreComponentCollection.h" #include "StaticData.h" +#include "moses/FF/StatelessFeatureFunction.h" +#include "moses/FF/StatefulFeatureFunction.h" using namespace std; @@ -301,6 +303,52 @@ void ScoreComponentCollection::PlusEquals(const FeatureFunction* sp, const Score } } +void ScoreComponentCollection::OutputAllFeatureScores(std::ostream &out) const +{ + std::string lastName = ""; + const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions(); + for( size_t i=0; i<sff.size(); i++ ) { + const StatefulFeatureFunction *ff = sff[i]; + if (ff->GetScoreProducerDescription() != "BleuScoreFeature" + && ff->IsTuneable()) { + OutputFeatureScores( out, ff, lastName ); + } + } + const vector<const StatelessFeatureFunction*>& slf = StatelessFeatureFunction::GetStatelessFeatureFunctions(); + for( size_t i=0; i<slf.size(); i++ ) { + const StatelessFeatureFunction *ff = slf[i]; + if (ff->IsTuneable()) { + OutputFeatureScores( out, ff, lastName ); + } + } +} + +void ScoreComponentCollection::OutputFeatureScores( std::ostream& out + , const FeatureFunction *ff + , std::string &lastName ) const +{ + const StaticData &staticData = StaticData::Instance(); + bool labeledOutput = staticData.IsLabeledNBestList(); + + // regular features (not sparse) + if (ff->GetNumScoreComponents() != 0) { + if( labeledOutput && lastName != ff->GetScoreProducerDescription() ) { + lastName = ff->GetScoreProducerDescription(); + out << " " << lastName << "="; + } + vector<float> scores = GetScoresForProducer( ff ); + for (size_t j = 0; j<scores.size(); ++j) { + out << " " << scores[j]; + } + } + + // sparse features + const FVector scores = GetVectorForProducer( ff ); + for(FVector::FNVmap::const_iterator i = scores.cbegin(); i != scores.cend(); i++) { + out << " " << i->first << "= " << i->second; + } +} + } |