blob: cea3bee1b5856517f1fc5e96d33197cc6d3faed6 (
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
59
60
61
62
63
64
65
66
67
68
69
|
/*
* HypothesisColl.h
*
* Created on: 26 Feb 2016
* Author: hieu
*/
#pragma once
#include <boost/unordered_set.hpp>
#include "HypothesisBase.h"
#include "MemPoolAllocator.h"
#include "Recycler.h"
#include "Array.h"
#include "legacy/Util2.h"
namespace Moses2
{
class ManagerBase;
class ArcLists;
typedef Array<const HypothesisBase*> Hypotheses;
class HypothesisColl
{
public:
HypothesisColl(const ManagerBase &mgr);
void Add(const System &system,
HypothesisBase *hypo,
Recycler<HypothesisBase*> &hypoRecycle,
ArcLists &arcLists);
size_t GetSize() const
{ return m_coll.size(); }
void Clear();
const Hypotheses &GetSortedAndPruneHypos(
const ManagerBase &mgr,
ArcLists &arcLists) const;
const Hypotheses &GetSortedAndPrunedHypos() const;
const HypothesisBase *GetBestHypo() const;
template<typename T>
const T *GetBestHypo() const
{
const HypothesisBase *hypo = GetBestHypo();
return hypo ? &hypo->Cast<T>() : NULL;
}
std::string Debug(const System &system) const;
protected:
typedef boost::unordered_set<const HypothesisBase*,
UnorderedComparer<HypothesisBase>, UnorderedComparer<HypothesisBase>,
MemPoolAllocator<const HypothesisBase*> > _HCType;
_HCType m_coll;
mutable Hypotheses *m_sortedHypos;
StackAdd Add(const HypothesisBase *hypo);
void SortAndPruneHypos(const ManagerBase &mgr, ArcLists &arcLists) const;
};
} /* namespace Moses2 */
|