mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 05:14:36 +03:00
move OutputInput() to Hypothesis class
This commit is contained in:
parent
af0d0f02e1
commit
f865e7e43c
@ -312,7 +312,7 @@ public:
|
||||
}
|
||||
if (addWordAlignInfo) {
|
||||
stringstream wordAlignment;
|
||||
IOWrapper::OutputAlignment(wordAlignment, hypo);
|
||||
hypo->OutputAlignment(wordAlignment);
|
||||
vector<xmlrpc_c::value> alignments;
|
||||
string alignmentPair;
|
||||
while (wordAlignment >> alignmentPair) {
|
||||
@ -475,7 +475,8 @@ public:
|
||||
|
||||
if ((int)edges.size() > 0) {
|
||||
stringstream wordAlignment;
|
||||
IOWrapper::OutputAlignment(wordAlignment, edges[0]);
|
||||
const Hypothesis *edge = edges[0];
|
||||
edge->OutputAlignment(wordAlignment);
|
||||
vector<xmlrpc_c::value> alignments;
|
||||
string alignmentPair;
|
||||
while (wordAlignment >> alignmentPair) {
|
||||
|
@ -472,5 +472,22 @@ void Hypothesis::OutputAlignment(ostream &out, const AlignmentInfo &ai, size_t s
|
||||
|
||||
}
|
||||
|
||||
void Hypothesis::OutputInput(std::vector<const Phrase*>& map, const Hypothesis* hypo)
|
||||
{
|
||||
if (hypo->GetPrevHypo()) {
|
||||
OutputInput(map, hypo->GetPrevHypo());
|
||||
map[hypo->GetCurrSourceWordsRange().GetStartPos()] = &hypo->GetTranslationOption().GetInputPath().GetPhrase();
|
||||
}
|
||||
}
|
||||
|
||||
void Hypothesis::OutputInput(std::ostream& os) const
|
||||
{
|
||||
size_t len = this->GetInput().GetSize();
|
||||
std::vector<const Phrase*> inp_phrases(len, 0);
|
||||
OutputInput(inp_phrases, this);
|
||||
for (size_t i=0; i<len; ++i)
|
||||
if (inp_phrases[i]) os << *inp_phrases[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -274,6 +274,9 @@ public:
|
||||
static void OutputAlignment(std::ostream &out, const std::vector<const Hypothesis *> &edges);
|
||||
static void OutputAlignment(std::ostream &out, const Moses::AlignmentInfo &ai, size_t sourceOffset, size_t targetOffset);
|
||||
|
||||
void OutputInput(std::ostream& os) const;
|
||||
static void OutputInput(std::vector<const Phrase*>& map, const Hypothesis* hypo);
|
||||
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Hypothesis& hypothesis);
|
||||
|
@ -593,24 +593,6 @@ void IOWrapper::OutputBestHypo(const std::vector<Word>& mbrBestHypo, long /*tra
|
||||
out << endl;
|
||||
}
|
||||
|
||||
|
||||
void IOWrapper::OutputInput(std::vector<const Phrase*>& map, const Hypothesis* hypo)
|
||||
{
|
||||
if (hypo->GetPrevHypo()) {
|
||||
OutputInput(map, hypo->GetPrevHypo());
|
||||
map[hypo->GetCurrSourceWordsRange().GetStartPos()] = &hypo->GetTranslationOption().GetInputPath().GetPhrase();
|
||||
}
|
||||
}
|
||||
|
||||
void IOWrapper::OutputInput(std::ostream& os, const Hypothesis* hypo)
|
||||
{
|
||||
size_t len = hypo->GetInput().GetSize();
|
||||
std::vector<const Phrase*> inp_phrases(len, 0);
|
||||
OutputInput(inp_phrases, hypo);
|
||||
for (size_t i=0; i<len; ++i)
|
||||
if (inp_phrases[i]) os << *inp_phrases[i];
|
||||
}
|
||||
|
||||
void IOWrapper::OutputBestHypo(const Hypothesis *hypo, long /*translationId*/, char reportSegmentation, bool reportAllFactors)
|
||||
{
|
||||
if (hypo != NULL) {
|
||||
@ -624,7 +606,7 @@ void IOWrapper::OutputBestHypo(const Hypothesis *hypo, long /*translationId*/, c
|
||||
}
|
||||
|
||||
if (StaticData::Instance().IsPathRecoveryEnabled()) {
|
||||
OutputInput(cout, hypo);
|
||||
hypo->OutputInput(cout);
|
||||
cout << "||| ";
|
||||
}
|
||||
OutputBestSurface(cout, hypo, *m_outputFactorOrder, reportSegmentation, reportAllFactors);
|
||||
|
@ -177,8 +177,6 @@ public:
|
||||
void OutputBestHypo(const std::vector<Moses::Word>& mbrBestHypo, long /*translationId*/,
|
||||
char reportSegmentation, bool reportAllFactors, std::ostream& out);
|
||||
void OutputBestHypo(const Moses::TrellisPath &path, long /*translationId*/,char reportSegmentation, bool reportAllFactors, std::ostream &out);
|
||||
void OutputInput(std::ostream& os, const Moses::Hypothesis* hypo);
|
||||
void OutputInput(std::vector<const Phrase*>& map, const Hypothesis* hypo);
|
||||
|
||||
void OutputPassthroughInformation(std::string& passthrough, const Moses::Hypothesis* hypo);
|
||||
void OutputPassthroughInformation(std::ostream& os, const Moses::Hypothesis* hypo);
|
||||
|
@ -117,7 +117,7 @@ void TranslationTask::RunPb()
|
||||
out << bestHypo->GetTotalScore() << ' ';
|
||||
}
|
||||
if (staticData.IsPathRecoveryEnabled()) {
|
||||
m_ioWrapper.OutputInput(out, bestHypo);
|
||||
bestHypo->OutputInput(out);
|
||||
out << "||| ";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user