mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 12:52:29 +03:00
Better labeling of feature values in lookup_mmsapt.
This commit is contained in:
parent
135ce20509
commit
c3db1a3a67
@ -1,5 +1,6 @@
|
|||||||
#include "mmsapt.h"
|
#include "mmsapt.h"
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
#include <boost/format.hpp>
|
||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -47,10 +48,13 @@ int main(int argc, char* argv[])
|
|||||||
if (!params.LoadParam(argc,argv) || !StaticData::LoadDataStatic(¶ms, argv[0]))
|
if (!params.LoadParam(argc,argv) || !StaticData::LoadDataStatic(¶ms, argv[0]))
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
Mmsapt* PT;
|
Mmsapt* PT = NULL;
|
||||||
BOOST_FOREACH(PhraseDictionary* pd, PhraseDictionary::GetColl())
|
BOOST_FOREACH(PhraseDictionary* pd, PhraseDictionary::GetColl())
|
||||||
if ((PT = dynamic_cast<Mmsapt*>(pd))) break;
|
if ((PT = dynamic_cast<Mmsapt*>(pd))) break;
|
||||||
|
vector<string> const& fname = PT->GetFeatureNames();
|
||||||
|
|
||||||
|
// vector<FeatureFunction*> const& ffs = FeatureFunction::GetFeatureFunctions();
|
||||||
|
|
||||||
string line;
|
string line;
|
||||||
while (getline(cin,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;
|
for (size_t i = 0; i < order.size(); ++i) order[i] = i;
|
||||||
sort(order.begin(),order.end(),TargetPhraseIndexSorter(*trg));
|
sort(order.begin(),order.end(),TargetPhraseIndexSorter(*trg));
|
||||||
size_t k = 0;
|
size_t k = 0;
|
||||||
|
// size_t precision =
|
||||||
|
cout.precision(2);
|
||||||
|
|
||||||
BOOST_FOREACH(size_t i, order)
|
BOOST_FOREACH(size_t i, order)
|
||||||
{
|
{
|
||||||
Phrase const& phr = static_cast<Phrase const&>(*(*trg)[i]);
|
Phrase const& phr = static_cast<Phrase const&>(*(*trg)[i]);
|
||||||
cout << setw(3) << ++k << " " << phr << endl;
|
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);
|
PT->Release(trg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user