diff options
author | Kenneth Heafield <github@kheafield.com> | 2012-10-15 16:58:33 +0400 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2012-10-15 16:58:33 +0400 |
commit | 0eb98df0fe32a8e31188fa107f789afd73d81ccf (patch) | |
tree | 6b2f5bb5a21e132f419da1fa7064f94eb74428e6 /search/vertex_generator.hh | |
parent | ed00315c8cf4c0b0f8ebc535cf676139b25ab087 (diff) |
Submodules are evil. Undo it.
Diffstat (limited to 'search/vertex_generator.hh')
-rw-r--r-- | search/vertex_generator.hh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/search/vertex_generator.hh b/search/vertex_generator.hh new file mode 100644 index 000000000..6b98da3e3 --- /dev/null +++ b/search/vertex_generator.hh @@ -0,0 +1,59 @@ +#ifndef SEARCH_VERTEX_GENERATOR__ +#define SEARCH_VERTEX_GENERATOR__ + +#include "search/note.hh" +#include "search/vertex.hh" + +#include <boost/unordered_map.hpp> + +#include <queue> + +namespace lm { +namespace ngram { +class ChartState; +} // namespace ngram +} // namespace lm + +namespace search { + +class ContextBase; +class Final; +struct PartialEdge; + +class VertexGenerator { + public: + VertexGenerator(ContextBase &context, Vertex &gen); + + void NewHypothesis(const PartialEdge &partial, Note note); + + void FinishedSearch() { + root_.under->SortAndSet(context_, NULL); + } + + const Vertex &Generating() const { return gen_; } + + private: + // Parallel structure to VertexNode. + struct Trie { + Trie() : under(NULL) {} + + VertexNode *under; + boost::unordered_map<uint64_t, Trie> extend; + }; + + Trie &FindOrInsert(Trie &node, uint64_t added, const lm::ngram::ChartState &state, unsigned char left, bool left_full, unsigned char right, bool right_full); + + Final *CompleteTransition(Trie &node, const lm::ngram::ChartState &state, Note note, const PartialEdge &partial); + + ContextBase &context_; + + Vertex &gen_; + + Trie root_; + + typedef boost::unordered_map<uint64_t, Final*> Existing; + Existing existing_; +}; + +} // namespace search +#endif // SEARCH_VERTEX_GENERATOR__ |