00001
00002 #include "moses/Hypothesis.h"
00003 #include "moses/Manager.h"
00004 #include <boost/foreach.hpp>
00005 namespace Moses {
00006 void
00007 Hypothesis::
00008 OutputLocalWordAlignment(std::vector<xmlrpc_c::value>& dest) const
00009 {
00010 using namespace std;
00011 Range const& src = this->GetCurrSourceWordsRange();
00012 Range const& trg = this->GetCurrTargetWordsRange();
00013
00014 WordAlignmentSort waso = m_manager.options()->output.WA_SortOrder;
00015 vector<pair<size_t,size_t> const* > a
00016 = this->GetCurrTargetPhrase().GetAlignTerm().GetSortedAlignments(waso);
00017 typedef pair<size_t,size_t> item;
00018 BOOST_FOREACH(item const* p, a) {
00019 map<string, xmlrpc_c::value> M;
00020 M["source-word"] = xmlrpc_c::value_int(src.GetStartPos() + p->first);
00021 M["target-word"] = xmlrpc_c::value_int(trg.GetStartPos() + p->second);
00022 dest.push_back(xmlrpc_c::value_struct(M));
00023 }
00024 }
00025
00026 void
00027 Hypothesis::
00028 OutputWordAlignment(std::vector<xmlrpc_c::value>& out) const
00029 {
00030 std::vector<Hypothesis const*> tmp;
00031 for (Hypothesis const* h = this; h; h = h->GetPrevHypo())
00032 tmp.push_back(h);
00033 for (size_t i = tmp.size(); i-- > 0;)
00034 tmp[i]->OutputLocalWordAlignment(out);
00035 }
00036
00037 }