diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-04-03 23:12:44 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-04-03 23:12:44 +0300 |
commit | 05c4e382ff7914369700eb516a61a45238292bdf (patch) | |
tree | e87b8626bf92a30978688d1514393bf3a976e9a0 /moses/TranslationModel/UG/mm | |
parent | 71005445d1b2f7a0f4b15a22ce953c3263a357a5 (diff) |
Better logging during biased sampling in Mmsapt.
Diffstat (limited to 'moses/TranslationModel/UG/mm')
-rw-r--r-- | moses/TranslationModel/UG/mm/ug_bitext.h | 11 | ||||
-rw-r--r-- | moses/TranslationModel/UG/mm/ug_sampling_bias.cc | 24 | ||||
-rw-r--r-- | moses/TranslationModel/UG/mm/ug_sampling_bias.h | 6 |
3 files changed, 28 insertions, 13 deletions
diff --git a/moses/TranslationModel/UG/mm/ug_bitext.h b/moses/TranslationModel/UG/mm/ug_bitext.h index ffde94b3a..bd2975cf7 100644 --- a/moses/TranslationModel/UG/mm/ug_bitext.h +++ b/moses/TranslationModel/UG/mm/ug_bitext.h @@ -419,7 +419,7 @@ namespace Moses { SortDescendingByJointCount:: cmp(PhrasePair const& a, PhrasePair const& b) const { - size_t i = 0; + // size_t i = 0; if (a.joint == b.joint) return 0; return a.joint > b.joint ? -1 : 1; } @@ -556,7 +556,8 @@ namespace Moses { loadSentenceBias(string const& fname) const; sptr<DocumentBias> - SetupDocumentBias(string const& bserver, string const& text) const; + SetupDocumentBias(string const& bserver, string const& text, + ostream* log) const; }; @@ -1522,10 +1523,12 @@ namespace Moses { template<typename Token> sptr<DocumentBias> Bitext<Token>:: - SetupDocumentBias(string const& bserver, string const& text) const + SetupDocumentBias + ( string const& bserver, string const& text, ostream* log ) const { sptr<DocumentBias> ret; - ret.reset(new DocumentBias(*m_sid2docid, m_docname2docid, bserver, text)); + ret.reset(new DocumentBias(*m_sid2docid, m_docname2docid, + bserver, text, log)); return ret; } diff --git a/moses/TranslationModel/UG/mm/ug_sampling_bias.cc b/moses/TranslationModel/UG/mm/ug_sampling_bias.cc index ae0c85baf..cc1717596 100644 --- a/moses/TranslationModel/UG/mm/ug_sampling_bias.cc +++ b/moses/TranslationModel/UG/mm/ug_sampling_bias.cc @@ -32,18 +32,20 @@ namespace Moses ::DocumentBias ( std::vector<id_type> const& sid2doc, std::map<std::string,id_type> const& docname2docid, - std::string const& server_url, std::string const& text) + std::string const& server_url, std::string const& text, + std::ostream* log) : m_sid2docid(sid2doc) , m_bias(docname2docid.size(), 0) { std::string json = query_bias_server(server_url, text); - init_from_json(json, docname2docid); + init_from_json(json, docname2docid, log); } void DocumentBias ::init_from_json - ( std::string const& json, std::map<std::string,id_type> const& docname2docid ) + ( std::string const& json, std::map<std::string,id_type> const& docname2docid, + std::ostream* log) { // poor man's special purpose json parser for responses from the // MMT bias server @@ -63,10 +65,18 @@ namespace Moses typedef std::pair<std::string const,float> item; if (total) { BOOST_FOREACH(item& x, bias) { x.second /= total; } } - BOOST_FOREACH(item& x, bias) - std::cerr << "CONTEXT SERVER RESPONSE " - << x.first << " " << x.second << std::endl; - + if (log) + { + BOOST_FOREACH(item& x, bias) + { + std::map<std::string,id_type>::const_iterator m; + m = docname2docid.find(x.first); + int docid = m != docname2docid.end() ? m->second : -1; + *log << "CONTEXT SERVER RESPONSE " + << "[" << docid << "] " + << x.first << " " << x.second << std::endl; + } + } init(bias, docname2docid); // using xmlrpc_parse_json didn't always work (parser errors) diff --git a/moses/TranslationModel/UG/mm/ug_sampling_bias.h b/moses/TranslationModel/UG/mm/ug_sampling_bias.h index 1fa1b3aa9..f7c95f439 100644 --- a/moses/TranslationModel/UG/mm/ug_sampling_bias.h +++ b/moses/TranslationModel/UG/mm/ug_sampling_bias.h @@ -41,12 +41,14 @@ namespace Moses DocumentBias(std::vector<id_type> const& sid2doc, std::map<std::string,id_type> const& docname2docid, - std::string const& server_url, std::string const& text); + std::string const& server_url, std::string const& text, + std::ostream* log); void init_from_json ( std::string const& json, - std::map<std::string,id_type> const& docname2docid ); + std::map<std::string,id_type> const& docname2docid, + std::ostream* log ); void init |