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:
Diffstat (limited to 'contrib/moses2/PhraseBased/Normal/Stacks.cpp')
-rw-r--r--contrib/moses2/PhraseBased/Normal/Stacks.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/contrib/moses2/PhraseBased/Normal/Stacks.cpp b/contrib/moses2/PhraseBased/Normal/Stacks.cpp
new file mode 100644
index 000000000..4aab42347
--- /dev/null
+++ b/contrib/moses2/PhraseBased/Normal/Stacks.cpp
@@ -0,0 +1,67 @@
+/*
+ * Stacks.cpp
+ *
+ * Created on: 6 Nov 2015
+ * Author: hieu
+ */
+
+#include "Stacks.h"
+#include "../Manager.h"
+#include "../../System.h"
+
+using namespace std;
+
+namespace Moses2
+{
+
+namespace NSNormal
+{
+
+Stacks::Stacks(const Manager &mgr) :
+ m_mgr(mgr)
+{
+ // TODO Auto-generated constructor stub
+
+}
+
+Stacks::~Stacks()
+{
+ for (size_t i = 0; i < m_stacks.size(); ++i) {
+ delete m_stacks[i];
+ }
+}
+
+void Stacks::Init(const Manager &mgr, size_t numStacks)
+{
+ m_stacks.resize(numStacks);
+ for (size_t i = 0; i < m_stacks.size(); ++i) {
+ m_stacks[i] = new Stack(mgr);
+ }
+}
+
+std::string Stacks::Debug(const System &system) const
+{
+ stringstream out;
+ for (size_t i = 0; i < GetSize(); ++i) {
+ const Stack *stack = m_stacks[i];
+ if (stack) {
+ out << stack->GetSize() << " ";
+ }
+ else {
+ out << "N ";
+ }
+ }
+ return out.str();
+}
+
+void Stacks::Add(Hypothesis *hypo, Recycler<HypothesisBase*> &hypoRecycle,
+ ArcLists &arcLists)
+{
+ size_t numWordsCovered = hypo->GetBitmap().GetNumWordsCovered();
+ //cerr << "numWordsCovered=" << numWordsCovered << endl;
+ Stack &stack = *m_stacks[numWordsCovered];
+ stack.Add(m_mgr.system, hypo, hypoRecycle, arcLists);
+}
+
+}
+}