diff options
author | Kenneth Heafield <github@kheafield.com> | 2012-09-11 14:30:16 +0100 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2012-09-11 14:31:42 +0100 |
commit | 45c9efc7d558dbe160056f02e74df1fee5d2d0e5 (patch) | |
tree | 0c26a847b78b4c0d86507b21b7338beb98ff1e73 /klm/search/edge_generator.hh | |
parent | 8882e9ebe158aef382bb5544559ef7f2a553db62 (diff) |
Add search library to cdec (not used yet)
Diffstat (limited to 'klm/search/edge_generator.hh')
-rw-r--r-- | klm/search/edge_generator.hh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/klm/search/edge_generator.hh b/klm/search/edge_generator.hh new file mode 100644 index 00000000..e306dc61 --- /dev/null +++ b/klm/search/edge_generator.hh @@ -0,0 +1,54 @@ +#ifndef SEARCH_EDGE_GENERATOR__ +#define SEARCH_EDGE_GENERATOR__ + +#include "search/edge.hh" + +#include <boost/unordered_map.hpp> + +#include <functional> +#include <queue> + +namespace lm { +namespace ngram { +class ChartState; +} // namespace ngram +} // namespace lm + +namespace search { + +template <class Model> class Context; + +class VertexGenerator; + +struct PartialEdgePointerLess : std::binary_function<const PartialEdge *, const PartialEdge *, bool> { + bool operator()(const PartialEdge *first, const PartialEdge *second) const { + return *first < *second; + } +}; + +class EdgeGenerator { + public: + // True if it has a hypothesis. + bool Init(Edge &edge, VertexGenerator &parent); + + Score Top() const { + return top_; + } + + template <class Model> bool Pop(Context<Model> &context, VertexGenerator &parent); + + private: + const Rule &GetRule() const { + return from_->GetRule(); + } + + Score top_; + + typedef std::priority_queue<PartialEdge*, std::vector<PartialEdge*>, PartialEdgePointerLess> Generate; + Generate generate_; + + Edge *from_; +}; + +} // namespace search +#endif // SEARCH_EDGE_GENERATOR__ |