mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
formatting error
This commit is contained in:
parent
e9dfc9dcfb
commit
33fc7986de
@ -141,8 +141,9 @@ void Hypothesis::OutputToStream(std::ostream &out) const
|
||||
|
||||
const TargetPhrase<Moses2::Word> &tp = GetTargetPhrase();
|
||||
if (tp.GetSize()) {
|
||||
tp.OutputToStream(*this, out);
|
||||
out << " ";
|
||||
const SubPhrase<Moses2::Word> &subPhrase = static_cast<const InputPath&>(GetInputPath()).subPhrase;
|
||||
|
||||
tp.OutputToStream(subPhrase, m_mgr->system.options.input.placeholder_factor, out);
|
||||
}
|
||||
|
||||
if (m_path->range.GetStartPos() != NOT_FOUND) {
|
||||
|
@ -258,7 +258,7 @@ std::string Manager::OutputNBest()
|
||||
|
||||
if (ok) {
|
||||
++bestInd;
|
||||
out << transId << " |||";
|
||||
out << transId << " ||| ";
|
||||
path->OutputToStream(out, system);
|
||||
out << "\n";
|
||||
}
|
||||
|
@ -7,9 +7,11 @@
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include "TrellisPath.h"
|
||||
#include "../TrellisPaths.h"
|
||||
#include "Hypothesis.h"
|
||||
#include "InputPath.h"
|
||||
#include "../TrellisPaths.h"
|
||||
#include "../System.h"
|
||||
#include "../SubPhrase.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -109,8 +111,9 @@ std::string TrellisPath::OutputTargetPhrase(const System &system) const
|
||||
const TrellisNode &node = nodes[i];
|
||||
const Hypothesis *hypo = static_cast<const Hypothesis*>(node.GetHypo());
|
||||
//cerr << "hypo=" << hypo << " " << *hypo << endl;
|
||||
hypo->GetTargetPhrase().OutputToStream(*hypo, out);
|
||||
out << " ";
|
||||
const SubPhrase<Moses2::Word> &subPhrase = static_cast<const InputPath&>(hypo->GetInputPath()).subPhrase;
|
||||
|
||||
hypo->GetTargetPhrase().OutputToStream(subPhrase, system.options.input.placeholder_factor, out);
|
||||
}
|
||||
return out.str();
|
||||
}
|
||||
|
@ -85,17 +85,20 @@ public:
|
||||
|
||||
}
|
||||
|
||||
void OutputToStream(const Hypothesis &hypo, std::ostream &out) const
|
||||
void OutputToStream(const Phrase<Moses2::Word> &inputPhrase, FactorType placeholderFactor, std::ostream &out) const
|
||||
{
|
||||
size_t size = PhraseImplTemplate<WORD>::GetSize();
|
||||
if (size) {
|
||||
(*this)[0].OutputToStream(out);
|
||||
for (size_t i = 1; i < size; ++i) {
|
||||
const WORD &word = (*this)[i];
|
||||
out << " ";
|
||||
word.OutputToStream(out);
|
||||
std::map<size_t, const Factor*> placeholders;
|
||||
if (placeholderFactor != NOT_FOUND) {
|
||||
// creates map of target position -> factor for placeholders
|
||||
placeholders = GetPlaceholders(inputPhrase, placeholderFactor);
|
||||
}
|
||||
|
||||
size_t size = PhraseImplTemplate<WORD>::GetSize();
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
const WORD &word = (*this)[i];
|
||||
word.OutputToStream(out);
|
||||
out << " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual std::string Debug(const System &system) const
|
||||
@ -107,6 +110,23 @@ public:
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::map<size_t, const Factor*> GetPlaceholders(const Phrase<WORD> &inputPhrase, FactorType placeholderFactor) const
|
||||
{
|
||||
std::map<size_t, const Factor*> ret;
|
||||
|
||||
for (size_t sourcePos = 0; sourcePos < inputPhrase.GetSize(); ++sourcePos) {
|
||||
const Factor *factor = inputPhrase[sourcePos][placeholderFactor];
|
||||
if (factor) {
|
||||
std::set<size_t> targetPos = GetAlignTerm().GetAlignmentsForSource(sourcePos);
|
||||
UTIL_THROW_IF2(targetPos.size() != 1,
|
||||
"Placeholder should be aligned to 1, and only 1, word");
|
||||
ret[*targetPos.begin()] = factor;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected:
|
||||
Scores *m_scores;
|
||||
const AlignmentInfo *m_alignTerm;
|
||||
|
Loading…
Reference in New Issue
Block a user