Revert "share bitmaps"

This reverts commit db24036313.
This commit is contained in:
Hieu Hoang 2015-10-19 17:23:02 +01:00
parent fda97b0802
commit dd7bf06f95
7 changed files with 8 additions and 51 deletions

View File

@ -4,12 +4,6 @@
namespace Moses
{
Bitmaps::Bitmaps(size_t inputSize)
{
m_initBitmap = new WordsBitmap(inputSize);
m_coll.insert(m_initBitmap);
}
Bitmaps::~Bitmaps()
{
RemoveAllInColl(m_coll);
@ -19,25 +13,10 @@ const WordsBitmap &Bitmaps::GetBitmap(const WordsBitmap &bm)
{
Coll::const_iterator iter = m_coll.find(&bm);
if (iter == m_coll.end()) {
WordsBitmap *newBM = new WordsBitmap(bm);
WordsBitmap *newBM = new WordsBitmap(bm);
m_coll.insert(newBM);
return *newBM;
} else {
return **iter;
}
}
const WordsBitmap &Bitmaps::GetBitmap(const WordsBitmap &bm, const WordsRange &range)
{
WordsBitmap *newBM = new WordsBitmap(bm);
newBM->SetValue(range, true);
Coll::const_iterator iter = m_coll.find(newBM);
if (iter == m_coll.end()) {
m_coll.insert(newBM);
return *newBM;
} else {
delete newBM;
return **iter;
}
}

View File

@ -1,7 +1,6 @@
#pragma once
#include <boost/unordered_set.hpp>
#include <set>
#include "WordsBitmap.h"
#include "Util.h"
@ -10,19 +9,12 @@ namespace Moses
class Bitmaps
{
typedef boost::unordered_set<WordsRange, const WordsBitmap*> NextBitmaps;
typedef boost::unordered_set<const WordsBitmap*, UnorderedComparer<WordsBitmap>, UnorderedComparer<WordsBitmap> > Coll;
//typedef std::set<const WordsBitmap*, OrderedComparer<WordsBitmap> > Coll;
Coll m_coll;
const WordsBitmap *m_initBitmap;
public:
Bitmaps(size_t inputSize);
virtual ~Bitmaps();
const WordsBitmap &GetInitialBitmap() const
{ return *m_initBitmap; }
public:
virtual ~Bitmaps();
const WordsBitmap &GetBitmap(const WordsBitmap &bm);
const WordsBitmap &GetBitmap(const WordsBitmap &bm, const WordsRange &range);
};

View File

@ -46,7 +46,7 @@ namespace Moses
Hypothesis::
Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt)
: m_prevHypo(NULL)
, m_sourceCompleted(manager.GetBitmaps().GetInitialBitmap())
, m_sourceCompleted(source.GetSize(), manager.GetSource().m_sourceCompleted)
, m_sourceInput(source)
, m_currSourceWordsRange(
m_sourceCompleted.GetFirstGapPos()>0 ? 0 : NOT_FOUND,
@ -77,7 +77,7 @@ Hypothesis(Manager& manager, InputType const& source, const TranslationOption &i
Hypothesis::
Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt)
: m_prevHypo(&prevHypo)
, m_sourceCompleted(prevHypo.GetManager().GetBitmaps().GetBitmap(prevHypo.GetWordsBitmap(), transOpt.GetSourceWordsRange()) )
, m_sourceCompleted(prevHypo.m_sourceCompleted )
, m_sourceInput(prevHypo.m_sourceInput)
, m_currSourceWordsRange(transOpt.GetSourceWordsRange())
, m_currTargetWordsRange(prevHypo.m_currTargetWordsRange.GetEndPos() + 1,
@ -98,6 +98,8 @@ Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt)
// that this hypothesis has already translated!
assert(!m_sourceCompleted.Overlap(m_currSourceWordsRange));
//_hash_computed = false;
m_sourceCompleted.SetValue(m_currSourceWordsRange.GetStartPos(), m_currSourceWordsRange.GetEndPos(), true);
m_wordDeleted = transOpt.IsDeletionOption();
m_manager.GetSentenceStats().AddCreated();
}

View File

@ -72,7 +72,7 @@ class Hypothesis
protected:
const Hypothesis* m_prevHypo; /*! backpointer to previous hypothesis (from which this one was created) */
const WordsBitmap &m_sourceCompleted; /*! keeps track of which words have been translated so far */
WordsBitmap m_sourceCompleted; /*! keeps track of which words have been translated so far */
InputType const& m_sourceInput;
WordsRange m_currSourceWordsRange; /*! source word positions of the last phrase that was used to create this hypothesis */
WordsRange m_currTargetWordsRange; /*! target word positions of the last phrase that was used to create this hypothesis */

View File

@ -67,7 +67,6 @@ Manager::Manager(ttasksptr const& ttask)
: BaseManager(ttask)
, interrupted_flag(0)
, m_hypoId(0)
, m_bitmaps(ttask.get()->GetSource().get()->GetSize())
{
boost::shared_ptr<InputType> source = ttask->GetSource();
m_transOptColl = source->CreateTranslationOptionCollection(ttask);

View File

@ -35,7 +35,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "Search.h"
#include "SearchCubePruning.h"
#include "BaseManager.h"
#include "Bitmaps.h"
namespace Moses
{
@ -120,7 +119,6 @@ protected:
size_t interrupted_flag;
std::auto_ptr<SentenceStats> m_sentenceStats;
int m_hypoId; //used to number the hypos as they are created.
Bitmaps m_bitmaps;
void GetConnectedGraph(
std::map< int, bool >* pConnected,
@ -194,10 +192,6 @@ public:
void ResetSentenceStats(const InputType& source);
SentenceStats& GetSentenceStats() const;
Bitmaps &GetBitmaps() {
return m_bitmaps;
}
/***
*For Lattice MBR
*/

View File

@ -537,15 +537,6 @@ class FeatureFunction;
void PrintFeatureWeight(const FeatureFunction* ff);
void ShowWeights();
template<typename T>
class OrderedComparer
{
public:
bool operator()(const T* a, const T* b) const {
return (*a) < (*b);
}
};
template<typename T>
class UnorderedComparer
{