2010-04-08 21:16:10 +04:00
|
|
|
#ifndef moses_HypothesisStack_h
|
|
|
|
#define moses_HypothesisStack_h
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <set>
|
|
|
|
#include "Hypothesis.h"
|
|
|
|
#include "WordsBitmap.h"
|
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2010-04-12 14:04:35 +04:00
|
|
|
class Manager;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
/** abstract unique set of hypotheses that cover a certain number of words,
|
2012-06-27 03:45:02 +04:00
|
|
|
* ie. a stack in phrase-based decoding
|
|
|
|
*/
|
2010-04-08 21:16:10 +04:00
|
|
|
class HypothesisStack
|
|
|
|
{
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
protected:
|
2011-02-24 16:14:42 +03:00
|
|
|
typedef std::set< Hypothesis*, HypothesisRecombinationOrderer > _HCType;
|
|
|
|
_HCType m_hypos; /**< contains hypotheses */
|
2010-04-08 21:16:10 +04:00
|
|
|
Manager& m_manager;
|
|
|
|
|
|
|
|
public:
|
|
|
|
HypothesisStack(Manager& manager): m_manager(manager) {}
|
2011-02-24 16:14:42 +03:00
|
|
|
typedef _HCType::iterator iterator;
|
|
|
|
typedef _HCType::const_iterator const_iterator;
|
|
|
|
//! iterators
|
|
|
|
const_iterator begin() const {
|
|
|
|
return m_hypos.begin();
|
|
|
|
}
|
|
|
|
const_iterator end() const {
|
|
|
|
return m_hypos.end();
|
|
|
|
}
|
|
|
|
size_t size() const {
|
|
|
|
return m_hypos.size();
|
|
|
|
}
|
|
|
|
virtual inline float GetWorstScore() const {
|
|
|
|
return -std::numeric_limits<float>::infinity();
|
|
|
|
};
|
|
|
|
virtual float GetWorstScoreForBitmap( WordsBitmapID ) {
|
|
|
|
return -std::numeric_limits<float>::infinity();
|
|
|
|
};
|
2012-05-05 20:04:41 +04:00
|
|
|
virtual float GetWorstScoreForBitmap( const WordsBitmap& ) {
|
2011-02-24 16:14:42 +03:00
|
|
|
return -std::numeric_limits<float>::infinity();
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual ~HypothesisStack();
|
|
|
|
virtual bool AddPrune(Hypothesis *hypothesis) = 0;
|
|
|
|
virtual const Hypothesis *GetBestHypothesis() const = 0;
|
|
|
|
virtual std::vector<const Hypothesis*> GetSortedList() const = 0;
|
|
|
|
|
|
|
|
//! remove hypothesis pointed to by iterator but don't delete the object
|
|
|
|
virtual void Detach(const HypothesisStack::iterator &iter);
|
|
|
|
/** destroy Hypothesis pointed to by iterator (object pool version) */
|
|
|
|
virtual void Remove(const HypothesisStack::iterator &iter);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|