From c3db1a3a674db862ff044d38bbcc1b9e6af70263 Mon Sep 17 00:00:00 2001 From: Ulrich Germann Date: Sat, 14 Jun 2014 13:02:55 +0100 Subject: [PATCH] Better labeling of feature values in lookup_mmsapt. --- moses/TranslationModel/UG/lookup_mmsapt.cc | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/moses/TranslationModel/UG/lookup_mmsapt.cc b/moses/TranslationModel/UG/lookup_mmsapt.cc index 39ac23cc7..e295f1012 100644 --- a/moses/TranslationModel/UG/lookup_mmsapt.cc +++ b/moses/TranslationModel/UG/lookup_mmsapt.cc @@ -1,5 +1,6 @@ #include "mmsapt.h" #include +#include #include #include #include @@ -47,10 +48,13 @@ int main(int argc, char* argv[]) if (!params.LoadParam(argc,argv) || !StaticData::LoadDataStatic(¶ms, argv[0])) exit(1); - Mmsapt* PT; + Mmsapt* PT = NULL; BOOST_FOREACH(PhraseDictionary* pd, PhraseDictionary::GetColl()) if ((PT = dynamic_cast(pd))) break; + vector const& fname = PT->GetFeatureNames(); + // vector const& ffs = FeatureFunction::GetFeatureFunctions(); + string line; while (getline(cin,line)) { @@ -62,10 +66,34 @@ int main(int argc, char* argv[]) for (size_t i = 0; i < order.size(); ++i) order[i] = i; sort(order.begin(),order.end(),TargetPhraseIndexSorter(*trg)); size_t k = 0; + // size_t precision = + cout.precision(2); + BOOST_FOREACH(size_t i, order) { Phrase const& phr = static_cast(*(*trg)[i]); cout << setw(3) << ++k << " " << phr << endl; + ScoreComponentCollection const& scc = (*trg)[i]->GetScoreBreakdown(); + ScoreComponentCollection::IndexPair idx = scc.GetIndexes(PT); + FVector const& scores = scc.GetScoresVector(); + cout << " "; + for (size_t k = idx.first; k < idx.second; ++k) + cout << " " << format("%10.10s") % fname[k-idx.first]; + cout << endl; + cout << " "; + for (size_t k = idx.first; k < idx.second; ++k) + { + if (fname[k-idx.first].substr(0,3) == "log") + { + if(scores[k] < 0) + cout << " " << format("%10d") % round(exp(-scores[k])); + else + cout << " " << format("%10d") % round(exp(scores[k])); + } + else + cout << " " << format("%10.8f") % exp(scores[k]); + } + cout << endl; } PT->Release(trg); }