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
path: root/moses/LM
diff options
context:
space:
mode:
authorLane Schwartz <dowobeha@gmail.com>2016-11-14 22:26:34 +0300
committerLane Schwartz <dowobeha@gmail.com>2016-11-14 22:26:34 +0300
commit05006bf1e2c68395a63ebd21a4f7ee56e38f260f (patch)
treedc589aab6af2ea30b8e110921730fe0b1fe8edef /moses/LM
parentea9d3b7f3ea5c0a9210c906b96824695b8a77ede (diff)
Allow XML-RPC requests to update weights
Diffstat (limited to 'moses/LM')
-rw-r--r--moses/LM/Reloading.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/moses/LM/Reloading.h b/moses/LM/Reloading.h
index 7075cb429..88f8e8869 100644
--- a/moses/LM/Reloading.h
+++ b/moses/LM/Reloading.h
@@ -48,6 +48,32 @@ public:
virtual void InitializeForInput(ttasksptr const& ttask) {
VERBOSE(1, "ReloadingLM InitializeForInput" << std::endl);
+ // The context scope object for this translation task
+ // contains a map of translation task-specific data
+ boost::shared_ptr<Moses::ContextScope> contextScope = ttask->GetScope();
+
+ // The key to the map is this object
+ void const* key = static_cast<void const*>(this);
+
+ // The value stored in the map is a string representing a phrase table
+ boost::shared_ptr<string> value = contextScope->get<string>(key);
+
+ // Create a stream to read the phrase table data
+ stringstream strme(*(value.get()));
+
+ ofstream tmp;
+ tmp.open(m_file.c_str());
+
+ // Read the phrase table data, one line at a time
+ string line;
+ while (getline(strme, line)) {
+
+ tmp << line << "\n";
+
+ }
+
+ tmp.close();
+
LanguageModelKen<Model>::LoadModel(m_file, m_lazy ? util::LAZY : util::POPULATE_OR_READ);
};