diff options
author | Kenneth Heafield <github@kheafield.com> | 2012-09-12 12:01:26 +0100 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2012-09-12 12:01:26 +0100 |
commit | 143ba7317dcaee3058d66f9e6558316f88f95212 (patch) | |
tree | 8686672c35ae34340306aa59ebbb55bfcd91702d /klm/search/rule.hh | |
parent | dea088773b024d6d5c65eab2883910483f99bc0a (diff) |
Refactor search so that it knows even less, but keeps track of edge pointers
Diffstat (limited to 'klm/search/rule.hh')
-rw-r--r-- | klm/search/rule.hh | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/klm/search/rule.hh b/klm/search/rule.hh index 79192d40..920c64a7 100644 --- a/klm/search/rule.hh +++ b/klm/search/rule.hh @@ -2,9 +2,9 @@ #define SEARCH_RULE__ #include "lm/left.hh" +#include "lm/word_index.hh" #include "search/arity.hh" #include "search/types.hh" -#include "search/word.hh" #include <boost/array.hpp> @@ -19,14 +19,10 @@ class Rule { public: Rule() : arity_(0) {} - void AppendTerminal(Word w) { items_.push_back(w); } + static const lm::WordIndex kNonTerminal = lm::kMaxWordIndex; - void AppendNonTerminal() { - items_.resize(items_.size() + 1); - ++arity_; - } - - template <class Model> void FinishedAdding(const Context<Model> &context, Score additive, bool prepend_bos); + // 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_; } @@ -38,23 +34,14 @@ class Rule { return lexical_[index]; } - // For printing. - typedef const std::vector<Word> ItemsRet; - ItemsRet &Items() const { return items_; } - private: Score bound_, additive_; unsigned int arity_; - // TODO: pool? - std::vector<Word> items_; - std::vector<lm::ngram::ChartState> lexical_; }; -std::ostream &operator<<(std::ostream &o, const Rule &rule); - } // namespace search #endif // SEARCH_RULE__ |