blob: 71d2081e1b072ff1d1169233501a6e5f0dfe4c9a (
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#pragma once
#include <vector>
#include <boost/shared_ptr.hpp>
#include "moses/InputType.h"
#include "moses/BaseManager.h"
#include "moses/Syntax/KBestExtractor.h"
#include "moses/Syntax/SVertexStack.h"
#include "OovHandler.h"
#include "ParserCallback.h"
#include "PChart.h"
#include "SChart.h"
namespace Moses
{
namespace Syntax
{
class SDerivation;
struct SHyperedge;
namespace S2T
{
template<typename Parser>
class Manager : public BaseManager
{
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;
const std::set<Word> &GetUnknownWords() const { return m_oovs; }
void OutputNBest(OutputCollector *collector) const;
void OutputLatticeSamples(OutputCollector *collector) const
{}
void OutputAlignment(OutputCollector *collector) const
{}
void OutputDetailedTranslationReport(OutputCollector *collector) const;
void OutputUnknowns(OutputCollector *collector) const;
void OutputDetailedTreeFragmentsTranslationReport(OutputCollector *collector) const
{}
void OutputWordGraph(OutputCollector *collector) const
{}
void OutputSearchGraph(OutputCollector *collector) const
{}
void OutputSearchGraphSLF() const
{}
private:
void FindOovs(const PChart &, std::set<Word> &, std::size_t);
void InitializeCharts();
void InitializeParsers(PChart &, std::size_t);
void RecombineAndSort(const std::vector<SHyperedge*> &, SVertexStack &);
void PrunePChart(const SChart::Cell &, PChart::Cell &);
const InputType &m_source;
PChart m_pchart;
SChart m_schart;
std::set<Word> m_oovs;
boost::shared_ptr<typename Parser::RuleTrie> m_oovRuleTrie;
std::vector<boost::shared_ptr<Parser> > m_parsers;
// output
void OutputNBestList(OutputCollector *collector,
const Moses::Syntax::KBestExtractor::KBestVec &nBestList,
long translationId) const;
std::size_t OutputAlignmentNBest(Alignments &retAlign,
const Moses::Syntax::KBestExtractor::Derivation &derivation,
std::size_t startTarget) const;
size_t CalcSourceSize(const Syntax::KBestExtractor::Derivation &d) const;
};
} // S2T
} // Syntax
} // Moses
// Implementation
#include "Manager-inl.h"
|