summaryrefslogtreecommitdiff
path: root/klm/search/edge_generator.hh
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-09-11 14:30:16 +0100
committerKenneth Heafield <github@kheafield.com>2012-09-11 14:31:42 +0100
commit58d7f847cd5b3c56682e834a2d9b897c6943fafc (patch)
tree04b370b0d92240a4a60dbf921548c927e0a5f00d /klm/search/edge_generator.hh
parent7aa4baf365a80380bebacfc4d4a1ef1b9d757590 (diff)
Add search library to cdec (not used yet)
Diffstat (limited to 'klm/search/edge_generator.hh')
-rw-r--r--klm/search/edge_generator.hh54
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__