blob: 875ccc5ea0e7d8faff2f41e83c03f8c8a94f494d (
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
48
49
50
51
52
53
54
55
56
57
58
|
#ifndef SEARCH_EDGE_GENERATOR__
#define SEARCH_EDGE_GENERATOR__
#include "search/edge.hh"
#include "search/note.hh"
#include <boost/pool/pool.hpp>
#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:
EdgeGenerator(PartialEdge &root, unsigned char arity, Note note);
Score TopScore() const {
return top_score_;
}
Note GetNote() const {
return note_;
}
// Pop. If there's a complete hypothesis, return it. Otherwise return NULL.
template <class Model> PartialEdge *Pop(Context<Model> &context, boost::pool<> &partial_edge_pool);
private:
Score top_score_;
unsigned char arity_;
typedef std::priority_queue<PartialEdge*, std::vector<PartialEdge*>, PartialEdgePointerLess> Generate;
Generate generate_;
Note note_;
};
} // namespace search
#endif // SEARCH_EDGE_GENERATOR__
|