Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieu@hoang.co.uk>2014-08-13 21:03:05 +0400
committerHieu Hoang <hieu@hoang.co.uk>2014-08-13 21:03:05 +0400
commit94c44c03d5470694827243aa2f12d3a3b031fda4 (patch)
tree0f27b1e6b75ca3d76e7c407b3ea179cacd8a2f52 /moses/XmlOption.cpp
parent27eee55a57d08b2f2cd30cd28aa8ab5e1145cfec (diff)
parenta371e732c858abb2d4bcb09228cf17dc513bd682 (diff)
merge
Diffstat (limited to 'moses/XmlOption.cpp')
-rw-r--r--moses/XmlOption.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/moses/XmlOption.cpp b/moses/XmlOption.cpp
index b87999341..52779eaf9 100644
--- a/moses/XmlOption.cpp
+++ b/moses/XmlOption.cpp
@@ -31,6 +31,9 @@
#include "ReorderingConstraint.h"
#include "FactorCollection.h"
#include "moses/TranslationModel/PhraseDictionary.h"
+#if PT_UG
+#include "TranslationModel/UG/mmsapt.h"
+#endif
namespace Moses
{
@@ -313,6 +316,38 @@ bool ProcessAndStripXMLTags(string &line, vector<XmlOption*> &res, ReorderingCon
placeholders.push_back(std::pair<size_t, std::string>(startPos, entity));
}
+ // update: add new aligned sentence pair to Mmsapt identified by name
+ else if (tagName == "update") {
+#if PT_UG
+ // get model name and aligned sentence pair
+ string pdName = ParseXmlTagAttribute(tagContent,"name");
+ string source = ParseXmlTagAttribute(tagContent,"source");
+ string target = ParseXmlTagAttribute(tagContent,"target");
+ string alignment = ParseXmlTagAttribute(tagContent,"alignment");
+ // find PhraseDictionary by name
+ const vector<PhraseDictionary*> &pds = PhraseDictionary::GetColl();
+ PhraseDictionary* pd = NULL;
+ for (vector<PhraseDictionary*>::const_iterator i = pds.begin(); i != pds.end(); ++i) {
+ PhraseDictionary* curPd = *i;
+ if (curPd->GetScoreProducerDescription() == pdName) {
+ pd = curPd;
+ break;
+ }
+ }
+ if (pd == NULL) {
+ TRACE_ERR("ERROR: No PhraseDictionary with name " << pdName << ", no update" << endl);
+ return false;
+ }
+ // update model
+ VERBOSE(3,"Updating " << pdName << " ||| " << source << " ||| " << target << " ||| " << alignment << endl);
+ Mmsapt* pdsa = reinterpret_cast<Mmsapt*>(pd);
+ pdsa->add(source, target, alignment);
+#else
+ TRACE_ERR("ERROR: recompile with --with-mm to update PhraseDictionary at runtime" << endl);
+ return false;
+#endif
+ }
+
// default: opening tag that specifies translation options
else {
if (startPos > endPos) {