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 <hieuhoang@gmail.com>2015-10-20 15:04:35 +0300
committerHieu Hoang <hieuhoang@gmail.com>2015-10-20 15:45:05 +0300
commitc384ae29de180d1c343e57fce3a55c0bda05bb9e (patch)
treedfbbfec85b345b63bc49b420bf12b6d43176fd9b /moses/Bitmaps.cpp
parent3d8e5fa79e1577141f0540162519541bea5fe295 (diff)
use Bitmap& in Hypothesis. Now works for vanilla pb
Diffstat (limited to 'moses/Bitmaps.cpp')
-rw-r--r--moses/Bitmaps.cpp46
1 files changed, 40 insertions, 6 deletions
diff --git a/moses/Bitmaps.cpp b/moses/Bitmaps.cpp
index f4c78f914..151727ce8 100644
--- a/moses/Bitmaps.cpp
+++ b/moses/Bitmaps.cpp
@@ -1,24 +1,58 @@
+#include <boost/foreach.hpp>
#include "Bitmaps.h"
#include "Util.h"
+using namespace std;
namespace Moses
{
+Bitmaps::Bitmaps(size_t inputSize, const std::vector<bool> &initSourceCompleted)
+{
+ m_initBitmap = new WordsBitmap(inputSize, initSourceCompleted);
+ m_coll[m_initBitmap];
+}
+
Bitmaps::~Bitmaps()
{
- RemoveAllInColl(m_coll);
+ BOOST_FOREACH (const Coll::value_type& myPair, m_coll) {
+ const WordsBitmap *bm = myPair.first;
+ delete bm;
+ }
}
-const WordsBitmap &Bitmaps::GetBitmap(const WordsBitmap &bm)
+const WordsBitmap &Bitmaps::GetNextBitmap(const WordsBitmap &bm, const WordsRange &range)
{
- Coll::const_iterator iter = m_coll.find(&bm);
+ WordsBitmap *newBM = new WordsBitmap(bm);
+ newBM->SetValue(range, true);
+
+ Coll::const_iterator iter = m_coll.find(newBM);
if (iter == m_coll.end()) {
- WordsBitmap *newBM = new WordsBitmap(bm);
- m_coll.insert(newBM);
+ m_coll[newBM] = NextBitmaps();
return *newBM;
} else {
- return **iter;
+ return *iter->first;
+ }
+}
+
+const WordsBitmap &Bitmaps::GetBitmap(const WordsBitmap &bm, const WordsRange &range)
+{
+ Coll::iterator iter = m_coll.find(&bm);
+ assert(iter != m_coll.end());
+
+ const WordsBitmap *newBM;
+ NextBitmaps &next = iter->second;
+ NextBitmaps::const_iterator iterNext = next.find(range);
+ if (iterNext == next.end()) {
+ // not seen the link yet.
+ newBM = &GetNextBitmap(bm, range);
+ next[range] = newBM;
+ }
+ else {
+ // link exist
+ //std::cerr << "link exists" << endl;
+ newBM = iterNext->second;
}
+ return *newBM;
}
}