start word alignment info

This commit is contained in:
Hieu Hoang 2016-04-18 18:30:45 +04:00
parent c8f1c04603
commit 43220ea994
4 changed files with 24 additions and 1 deletions

View File

@ -65,7 +65,9 @@ TargetPhraseImpl::~TargetPhraseImpl()
std::ostream& operator<<(std::ostream &out, const TargetPhraseImpl &obj) 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; return out;
} }

View File

@ -71,6 +71,13 @@ public:
m_alignTerm = AlignmentInfoCollection::Instance().Add(coll); m_alignTerm = AlignmentInfoCollection::Instance().Add(coll);
} }
const AlignmentInfo &GetAlignTerm() const {
return *m_alignTerm;
}
const AlignmentInfo &GetAlignNonTerm() const {
return *m_alignNonTerm;
}
// ALNREP = alignment representation, // ALNREP = alignment representation,
// see AlignmentInfo constructors for supported representations // see AlignmentInfo constructors for supported representations
template<typename ALNREP> template<typename ALNREP>

View File

@ -55,6 +55,19 @@ size_t Word::hash() const
return ret; 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;
}
} }
} }

View File

@ -304,6 +304,7 @@ void PhraseTableMemory::AddTargetPhrasesToPath(const PhraseTableMemory::Node &no
for (iter = tps->begin(); iter != tps->end(); ++iter) { for (iter = tps->begin(); iter != tps->end(); ++iter) {
const TargetPhrase *tp = *iter; const TargetPhrase *tp = *iter;
const SCFG::TargetPhraseImpl *tpCast = static_cast<const SCFG::TargetPhraseImpl*>(tp); const SCFG::TargetPhraseImpl *tpCast = static_cast<const SCFG::TargetPhraseImpl*>(tp);
cerr << "tpCast=" << *tpCast << endl;
path.AddTargetPhrase(*this, tpCast); path.AddTargetPhrase(*this, tpCast);
} }
} }