Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HypothesisStack.h « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3641b2132031dd7b69cb172021c2d41b2e0d470a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef moses_HypothesisStack_h
#define moses_HypothesisStack_h

#include <vector>
#include <set>
#include <boost/unordered_set.hpp>
#include "Hypothesis.h"
#include "Bitmap.h"

namespace Moses
{

class Manager;

/** abstract unique set of hypotheses that cover a certain number of words,
 *  ie. a stack in phrase-based decoding
 */
class HypothesisStack
{

protected:
  typedef boost::unordered_set< Hypothesis*, UnorderedComparer<Hypothesis>, UnorderedComparer<Hypothesis> > _HCType;
  _HCType m_hypos; /**< contains hypotheses */
  Manager& m_manager;

public:
  HypothesisStack(Manager& manager): m_manager(manager) {}
  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();
  };
  virtual float GetWorstScoreForBitmap( const Bitmap& ) {
    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);

};

}

#endif