The server accepts an optional "report-all-factors" input parameter (boolean) to write all factors into the output text parameter, simulating the standard behavior of the standalone option

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@3956 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
lagunex 2011-05-11 10:18:57 +00:00
parent fb1a668bba
commit a8adc0d6f7

View File

@ -113,6 +113,8 @@ public:
bool addGraphInfo = (si != params.end());
si = params.find("topt");
bool addTopts = (si != params.end());
si = params.find("report-all-factors");
bool reportAllFactors = (si != params.end());
const StaticData &staticData = StaticData::Instance();
@ -133,7 +135,7 @@ public:
vector<xmlrpc_c::value> alignInfo;
stringstream out, graphInfo, transCollOpts;
outputHypo(out,hypo,addAlignInfo,alignInfo);
outputHypo(out,hypo,addAlignInfo,alignInfo,reportAllFactors);
map<string, xmlrpc_c::value> retData;
pair<string, xmlrpc_c::value>
@ -154,15 +156,19 @@ public:
*retvalP = xmlrpc_c::value_struct(retData);
}
void outputHypo(ostream& out, const Hypothesis* hypo, bool addAlignmentInfo, vector<xmlrpc_c::value>& alignInfo) {
void outputHypo(ostream& out, const Hypothesis* hypo, bool addAlignmentInfo, vector<xmlrpc_c::value>& alignInfo, bool reportAllFactors = false) {
if (hypo->GetPrevHypo() != NULL) {
outputHypo(out,hypo->GetPrevHypo(),addAlignmentInfo, alignInfo);
TargetPhrase p = hypo->GetTargetPhrase();
for (size_t pos = 0 ; pos < p.GetSize() ; pos++) {
const Factor *factor = p.GetFactor(pos, 0);
out << *factor << " ";
outputHypo(out,hypo->GetPrevHypo(),addAlignmentInfo, alignInfo, reportAllFactors);
Phrase p = hypo->GetTargetPhrase();
if(reportAllFactors) {
out << p << " ";
} else {
for (size_t pos = 0 ; pos < p.GetSize() ; pos++) {
const Factor *factor = p.GetFactor(pos, 0);
out << *factor << " ";
}
}
if (addAlignmentInfo) {
/**
* Add the alignment info to the array. This is in target order and consists of