blob: 90f34c04b08297da56c1c7f9d15072608025ecf3 (
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
70
71
72
|
#pragma once
#include <set>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/unordered_map.hpp>
#include "moses/InputType.h"
#include "moses/Syntax/KBestExtractor.h"
#include "moses/Syntax/Manager.h"
#include "moses/Syntax/SVertexStack.h"
#include "moses/Word.h"
#include "Forest.h"
#include "HyperTree.h"
#include "PVertexToStackMap.h"
namespace Moses
{
namespace Syntax
{
struct SHyperedge;
namespace F2S
{
template<typename RuleMatcher>
class Manager : public Syntax::Manager
{
public:
Manager(const InputType &);
void Decode();
// Get the SHyperedge for the 1-best derivation.
const SHyperedge *GetBestSHyperedge() const;
void ExtractKBest(
std::size_t k,
std::vector<boost::shared_ptr<KBestExtractor::Derivation> > &kBestList,
bool onlyDistinct=false) const;
void OutputDetailedTranslationReport(OutputCollector *collector) const;
private:
const Forest::Vertex &FindRootNode(const Forest &);
void InitializeRuleMatchers();
void InitializeStacks();
bool IsUnknownSourceWord(const Word &) const;
void RecombineAndSort(const std::vector<SHyperedge*> &, SVertexStack &);
boost::shared_ptr<const Forest> m_forest;
const Forest::Vertex *m_rootVertex;
std::size_t m_sentenceLength; // Includes <s> and </s>
PVertexToStackMap m_stackMap;
boost::shared_ptr<HyperTree> m_glueRuleTrie;
std::vector<boost::shared_ptr<RuleMatcher> > m_mainRuleMatchers;
boost::shared_ptr<RuleMatcher> m_glueRuleMatcher;
};
} // F2S
} // Syntax
} // Moses
// Implementation
#include "Manager-inl.h"
|