// -*- mode: c++; indent-tabs-mode: nil; tab-width:2 -*- #include "moses/Hypothesis.h" #include "moses/Manager.h" #include namespace Moses { void Hypothesis:: OutputLocalWordAlignment(std::vector& dest) const { using namespace std; Range const& src = this->GetCurrSourceWordsRange(); Range const& trg = this->GetCurrTargetWordsRange(); WordAlignmentSort waso = m_manager.options()->output.WA_SortOrder; vector const* > a = this->GetCurrTargetPhrase().GetAlignTerm().GetSortedAlignments(waso); typedef pair item; BOOST_FOREACH(item const* p, a) { map M; M["source-word"] = xmlrpc_c::value_int(src.GetStartPos() + p->first); M["target-word"] = xmlrpc_c::value_int(trg.GetStartPos() + p->second); dest.push_back(xmlrpc_c::value_struct(M)); } } void Hypothesis:: OutputWordAlignment(std::vector& out) const { std::vector tmp; for (Hypothesis const* h = this; h; h = h->GetPrevHypo()) tmp.push_back(h); for (size_t i = tmp.size(); i-- > 0;) tmp[i]->OutputLocalWordAlignment(out); } }