mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-26 19:37:58 +03:00
parent
fda97b0802
commit
dd7bf06f95
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
};
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user