File size: 1,349 Bytes
158b61b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#pragma once

#include <set>
#include <vector>

#include <boost/shared_ptr.hpp>
#include <boost/unordered_map.hpp>

#include "moses/Syntax/F2S/PVertexToStackMap.h"
#include "moses/Syntax/KBestExtractor.h"
#include "moses/Syntax/Manager.h"
#include "moses/Syntax/SVertexStack.h"
#include "moses/TreeInput.h"
#include "moses/Word.h"

#include "InputTree.h"
#include "RuleTrie.h"

namespace Moses
{
namespace Syntax
{

struct SHyperedge;

namespace T2S
{

template<typename RuleMatcher>
class Manager : public Syntax::Manager
{
public:
  Manager(ttasksptr const& ttask);

  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:
  void InitializeRuleMatchers();

  void InitializeStacks();

  void RecombineAndSort(const std::vector<SHyperedge*> &, SVertexStack &);

  InputTree m_inputTree;
  F2S::PVertexToStackMap m_stackMap;
  boost::shared_ptr<RuleTrie> m_glueRuleTrie;
  std::vector<boost::shared_ptr<RuleMatcher> > m_ruleMatchers;
  RuleMatcher *m_glueRuleMatcher;
};

}  // T2S
}  // Syntax
}  // Moses

// Implementation
#include "Manager-inl.h"