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:
-rw-r--r--moses/src/Incremental/Fill.cpp9
-rw-r--r--moses/src/Incremental/Fill.h8
-rw-r--r--moses/src/Incremental/Manager.cpp7
-rw-r--r--moses/src/Incremental/Manager.h2
-rw-r--r--moses/src/Incremental/Owner.h19
5 files changed, 12 insertions, 33 deletions
diff --git a/moses/src/Incremental/Fill.cpp b/moses/src/Incremental/Fill.cpp
index 15d18c893..2246ea3a3 100644
--- a/moses/src/Incremental/Fill.cpp
+++ b/moses/src/Incremental/Fill.cpp
@@ -1,6 +1,5 @@
#include "Incremental/Fill.h"
-#include "Incremental/Owner.h"
#include "ChartCellLabel.h"
#include "ChartCellLabelSet.h"
#include "TargetPhraseCollection.h"
@@ -18,8 +17,8 @@
namespace Moses {
namespace Incremental {
-template <class Model> Fill<Model>::Fill(search::Context<Model> &context, const std::vector<lm::WordIndex> &vocab_mapping, Owner &owner)
- : context_(context), vocab_mapping_(vocab_mapping), owner_(owner), edges_(context.PopLimit()) {}
+template <class Model> Fill<Model>::Fill(search::Context<Model> &context, const std::vector<lm::WordIndex> &vocab_mapping)
+ : context_(context), vocab_mapping_(vocab_mapping), edges_(context.PopLimit()) {}
template <class Model> void Fill<Model>::Add(const TargetPhraseCollection &targets, const StackVec &nts, const WordsRange &) {
const unsigned char arity = nts.size();
@@ -124,8 +123,8 @@ class HypothesisCallback {
};
} // namespace
-template <class Model> void Fill<Model>::Search(ChartCellLabelSet &out) {
- HypothesisCallback callback(context_, out, owner_.VertexPool());
+template <class Model> void Fill<Model>::Search(ChartCellLabelSet &out, boost::object_pool<search::Vertex> &vertex_pool) {
+ HypothesisCallback callback(context_, out, vertex_pool);
edges_.Search(context_, callback);
}
diff --git a/moses/src/Incremental/Fill.h b/moses/src/Incremental/Fill.h
index 91b597006..d6d9d4f54 100644
--- a/moses/src/Incremental/Fill.h
+++ b/moses/src/Incremental/Fill.h
@@ -13,6 +13,7 @@
namespace search {
template <class Model> class Context;
+class Vertex;
} // namespace search
namespace Moses {
@@ -24,13 +25,12 @@ class ChartCellLabelSet;
class TargetPhrase;
namespace Incremental {
-class Owner;
// Replacement for ChartTranslationOptionList
// TODO: implement count and score thresholding.
template <class Model> class Fill : public ChartParserCallback {
public:
- Fill(search::Context<Model> &context, const std::vector<lm::WordIndex> &vocab_mapping, Owner &owner);
+ Fill(search::Context<Model> &context, const std::vector<lm::WordIndex> &vocab_mapping);
void Add(const TargetPhraseCollection &targets, const StackVec &nts, const WordsRange &ignored);
@@ -38,7 +38,7 @@ template <class Model> class Fill : public ChartParserCallback {
bool Empty() const { return edges_.Empty(); }
- void Search(ChartCellLabelSet &out);
+ void Search(ChartCellLabelSet &out, boost::object_pool<search::Vertex> &vertex_pool);
private:
lm::WordIndex Convert(const Word &word) const ;
@@ -47,8 +47,6 @@ template <class Model> class Fill : public ChartParserCallback {
const std::vector<lm::WordIndex> &vocab_mapping_;
- Owner &owner_;
-
search::EdgeQueue edges_;
};
diff --git a/moses/src/Incremental/Manager.cpp b/moses/src/Incremental/Manager.cpp
index 0d63c641c..f6a13c14a 100644
--- a/moses/src/Incremental/Manager.cpp
+++ b/moses/src/Incremental/Manager.cpp
@@ -89,13 +89,16 @@ template <class Model> void Manager::LMCallback(const Model &model, const std::v
search::Context<Model> context(config, model);
size_t size = source_.GetSize();
+
+ boost::object_pool<search::Vertex> vertex_pool(std::max<size_t>(size * size / 2, 32));
+
for (size_t width = 1; width <= size; ++width) {
for (size_t startPos = 0; startPos <= size-width; ++startPos) {
size_t endPos = startPos + width - 1;
WordsRange range(startPos, endPos);
- Fill<Model> filler(context, words, owner_);
+ Fill<Model> filler(context, words);
parser_.Create(range, filler);
- filler.Search(cells_.MutableBase(range).MutableTargetLabelSet());
+ filler.Search(cells_.MutableBase(range).MutableTargetLabelSet(), vertex_pool);
}
}
BestString(cells_.GetBase(WordsRange(0, source_.GetSize() - 1)).GetTargetLabelSet(), output_);
diff --git a/moses/src/Incremental/Manager.h b/moses/src/Incremental/Manager.h
index b9105481f..1ca51a5c4 100644
--- a/moses/src/Incremental/Manager.h
+++ b/moses/src/Incremental/Manager.h
@@ -4,7 +4,6 @@
#include "ChartCellCollection.h"
#include "ChartParser.h"
-#include "Incremental/Owner.h"
namespace Moses {
class InputType;
@@ -28,7 +27,6 @@ class Manager {
const TranslationSystem &system_;
ChartCellCollectionBase cells_;
ChartParser parser_;
- Owner owner_;
std::string output_;
};
diff --git a/moses/src/Incremental/Owner.h b/moses/src/Incremental/Owner.h
deleted file mode 100644
index a7292afc9..000000000
--- a/moses/src/Incremental/Owner.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-
-#include "search/vertex.hh"
-
-#include <boost/pool/object_pool.hpp>
-
-namespace Moses {
-namespace Incremental {
-
-class Owner {
- public:
- boost::object_pool<search::Vertex> &VertexPool() { return vertices_; }
-
- private:
- boost::object_pool<search::Vertex> vertices_;
-};
-
-} // namespace Incremental
-} // namespace Moses