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

HypothesisBase.h « moses2 - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 55747990667b886913227c27cfee933b945e6c54 (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
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Hypothesis.h
 *
 *  Created on: 24 Oct 2015
 *      Author: hieu
 */
#pragma once

#include <iostream>
#include <cstddef>
#include "FF/FFState.h"
#include "Scores.h"

namespace Moses2
{

class ManagerBase;
class Scores;

class HypothesisBase
{
public:
  virtual ~HypothesisBase() {
  }

  inline ManagerBase &GetManager() const {
    return *m_mgr;
  }

  template<typename T>
  const T &Cast() const {
    return static_cast<const T&>(*this);
  }

  const Scores &GetScores() const {
    return *m_scores;
  }
  Scores &GetScores() {
    return *m_scores;
  }

  const FFState *GetState(size_t ind) const {
    return m_ffStates[ind];
  }
  FFState *GetState(size_t ind) {
    return m_ffStates[ind];
  }

  virtual size_t hash() const;
  virtual size_t hash(size_t seed) const;
  virtual bool operator==(const HypothesisBase &other) const;

  virtual SCORE GetFutureScore() const = 0;
  virtual void EvaluateWhenApplied() = 0;

  virtual std::string Debug(const System &system) const = 0;

protected:
  ManagerBase *m_mgr;
  Scores *m_scores;
  FFState **m_ffStates;

  HypothesisBase(MemPool &pool, const System &system);
};

////////////////////////////////////////////////////////////////////////////////////
class HypothesisFutureScoreOrderer
{
public:
  bool operator()(const HypothesisBase* a, const HypothesisBase* b) const {
    return a->GetFutureScore() > b->GetFutureScore();
  }
};

}