From 43220ea9949f57145fdbf9193425b2659f4e65ee Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Mon, 18 Apr 2016 18:30:45 +0400 Subject: [PATCH] start word alignment info --- .../other-builds/moses2/SCFG/TargetPhraseImpl.cpp | 4 +++- contrib/other-builds/moses2/SCFG/TargetPhraseImpl.h | 7 +++++++ contrib/other-builds/moses2/SCFG/Word.cpp | 13 +++++++++++++ .../moses2/TranslationModel/PhraseTableMemory.cpp | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.cpp b/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.cpp index 8ed45495d..cc00700af 100644 --- a/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.cpp +++ b/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.cpp @@ -65,7 +65,9 @@ TargetPhraseImpl::~TargetPhraseImpl() std::ostream& operator<<(std::ostream &out, const TargetPhraseImpl &obj) { - out << (const Phrase&) obj << " SCORES:" << obj.GetScores(); + out << obj.lhs << " -> " << (const Phrase&) obj + << " SCORES:" << obj.GetScores() + << " ALIGN:" << obj.GetAlignTerm() << " " << obj.GetAlignNonTerm(); return out; } diff --git a/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.h b/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.h index 401e29ca3..015e945d7 100644 --- a/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.h +++ b/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.h @@ -71,6 +71,13 @@ public: m_alignTerm = AlignmentInfoCollection::Instance().Add(coll); } + const AlignmentInfo &GetAlignTerm() const { + return *m_alignTerm; + } + const AlignmentInfo &GetAlignNonTerm() const { + return *m_alignNonTerm; + } + // ALNREP = alignment representation, // see AlignmentInfo constructors for supported representations template diff --git a/contrib/other-builds/moses2/SCFG/Word.cpp b/contrib/other-builds/moses2/SCFG/Word.cpp index 2fbbef819..16532493b 100644 --- a/contrib/other-builds/moses2/SCFG/Word.cpp +++ b/contrib/other-builds/moses2/SCFG/Word.cpp @@ -55,6 +55,19 @@ size_t Word::hash() const return ret; } +std::ostream& operator<<(std::ostream &out, const SCFG::Word &obj) +{ + if (obj.isNonTerminal) { + out << "["; + } + out << (const Moses2::Word&) obj; + if (obj.isNonTerminal) { + out << "]"; + } + + return out; +} + } } diff --git a/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp b/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp index 96ff9e594..7de76d67e 100644 --- a/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp +++ b/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp @@ -304,6 +304,7 @@ void PhraseTableMemory::AddTargetPhrasesToPath(const PhraseTableMemory::Node &no for (iter = tps->begin(); iter != tps->end(); ++iter) { const TargetPhrase *tp = *iter; const SCFG::TargetPhraseImpl *tpCast = static_cast(tp); + cerr << "tpCast=" << *tpCast << endl; path.AddTargetPhrase(*this, tpCast); } }