mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
delete hardcoded if() statements for show weights. Excluded UnknownWordPenalty and made sure PhraseModel & Generation is in particular order
This commit is contained in:
parent
28b70a5697
commit
08ca44b34e
@ -67,6 +67,13 @@ using namespace std;
|
||||
using namespace Moses;
|
||||
using namespace MosesChartCmd;
|
||||
|
||||
/** Enforce rounding */
|
||||
void fix(std::ostream& stream, size_t size)
|
||||
{
|
||||
stream.setf(std::ios::fixed);
|
||||
stream.precision(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a sentence.
|
||||
**/
|
||||
@ -200,50 +207,18 @@ static void PrintFeatureWeight(const FeatureFunction* ff)
|
||||
|
||||
static void ShowWeights()
|
||||
{
|
||||
cout.precision(6);
|
||||
fix(cout,6);
|
||||
const StaticData& staticData = StaticData::Instance();
|
||||
const TranslationSystem& system = staticData.GetTranslationSystem(TranslationSystem::DEFAULT);
|
||||
//This has to match the order in the nbest list
|
||||
|
||||
//LMs
|
||||
const LMList& lml = system.GetLanguageModels();
|
||||
LMList::const_iterator lmi = lml.begin();
|
||||
for (; lmi != lml.end(); ++lmi) {
|
||||
PrintFeatureWeight(*lmi);
|
||||
}
|
||||
|
||||
//sparse stateful ffs
|
||||
const vector<const StatelessFeatureFunction*>& slf =system.GetStatelessFeatureFunctions();
|
||||
const vector<const StatefulFeatureFunction*>& sff = system.GetStatefulFeatureFunctions();
|
||||
for( size_t i=0; i<sff.size(); i++ ) {
|
||||
if (sff[i]->GetNumScoreComponents() == ScoreProducer::unlimited) {
|
||||
PrintFeatureWeight(sff[i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sff.size(); ++i) {
|
||||
PrintFeatureWeight(sff[i]);
|
||||
}
|
||||
|
||||
// translation components - phrase dicts
|
||||
const vector<PhraseDictionaryFeature*>& pds = system.GetPhraseDictionaries();
|
||||
for( size_t i=0; i<pds.size(); i++ ) {
|
||||
PrintFeatureWeight(pds[i]);
|
||||
for (size_t i = 0; i < slf.size(); ++i) {
|
||||
PrintFeatureWeight(slf[i]);
|
||||
}
|
||||
|
||||
//word penalty
|
||||
PrintFeatureWeight(system.GetWordPenaltyProducer());
|
||||
|
||||
//generation dicts
|
||||
const vector<GenerationDictionary*>& gds = system.GetGenerationDictionaries();
|
||||
for( size_t i=0; i<gds.size(); i++ ) {
|
||||
PrintFeatureWeight(gds[i]);
|
||||
}
|
||||
|
||||
//sparse stateless ffs
|
||||
const vector<const StatelessFeatureFunction*>& slf = system.GetStatelessFeatureFunctions();
|
||||
for( size_t i=0; i<slf.size(); i++ ) {
|
||||
if (slf[i]->GetNumScoreComponents() == ScoreProducer::unlimited) {
|
||||
PrintFeatureWeight(slf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -337,6 +337,7 @@ static void ShowWeights()
|
||||
const TranslationSystem& system = staticData.GetTranslationSystem(TranslationSystem::DEFAULT);
|
||||
const vector<const StatelessFeatureFunction*>& slf =system.GetStatelessFeatureFunctions();
|
||||
const vector<const StatefulFeatureFunction*>& sff = system.GetStatefulFeatureFunctions();
|
||||
|
||||
for (size_t i = 0; i < sff.size(); ++i) {
|
||||
PrintFeatureWeight(sff[i]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user