summaryrefslogtreecommitdiff
path: root/klm/search/rule.hh
blob: 920c64a74239de658cfc3170069f0d97e772e909 (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
#ifndef SEARCH_RULE__
#define SEARCH_RULE__

#include "lm/left.hh"
#include "lm/word_index.hh"
#include "search/arity.hh"
#include "search/types.hh"

#include <boost/array.hpp>

#include <iosfwd>
#include <vector>

namespace search {

template <class Model> class Context;

class Rule {
  public:
    Rule() : arity_(0) {}

    static const lm::WordIndex kNonTerminal = lm::kMaxWordIndex;

    // Use kNonTerminal for non-terminals.  
    template <class Model> void Init(const Context<Model> &context, Score additive, const std::vector<lm::WordIndex> &words, bool prepend_bos);

    Score Bound() const { return bound_; }

    Score Additive() const { return additive_; }

    unsigned int Arity() const { return arity_; }

    const lm::ngram::ChartState &Lexical(unsigned int index) const {
      return lexical_[index];
    }

  private:
    Score bound_, additive_;

    unsigned int arity_;

    std::vector<lm::ngram::ChartState> lexical_;
};

} // namespace search

#endif // SEARCH_RULE__