blob: 60e86112a1c999732a0f585c8203546ae0079986 (
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
|
#ifndef SEARCH_VERTEX_GENERATOR__
#define SEARCH_VERTEX_GENERATOR__
#include "search/edge.hh"
#include "search/vertex.hh"
#include <boost/unordered_map.hpp>
namespace lm {
namespace ngram {
class ChartState;
} // namespace ngram
} // namespace lm
namespace search {
class ContextBase;
class Final;
class VertexGenerator {
public:
VertexGenerator(ContextBase &context, Vertex &gen);
void NewHypothesis(PartialEdge partial) {
const lm::ngram::ChartState &state = partial.CompletedState();
std::pair<Existing::iterator, bool> ret(existing_.insert(std::make_pair(hash_value(state), partial)));
if (!ret.second && ret.first->second < partial) {
ret.first->second = partial;
}
}
void FinishedSearch();
const Vertex &Generating() const { return gen_; }
private:
ContextBase &context_;
Vertex &gen_;
typedef boost::unordered_map<uint64_t, PartialEdge> Existing;
Existing existing_;
};
} // namespace search
#endif // SEARCH_VERTEX_GENERATOR__
|