File size: 1,762 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 68 69 70 71 72 73 74 |
#pragma once
#include <memory>
#include <vector>
#include "moses/Syntax/S2T/Parsers/Parser.h"
#include "moses/Syntax/S2T/RuleTrieScope3.h"
#include "moses/Range.h"
#include "PatternApplicationTrie.h"
#include "SymbolRangeCalculator.h"
#include "TailLattice.h"
#include "TailLatticeBuilder.h"
namespace Moses
{
namespace Syntax
{
namespace S2T
{
// Parser that implements the algorithm described in this paper:
//
// Philip Williams and Philipp Koehn
// "GHKM Rule Extraction and Scope-3 Parsing in Moses"
// In proceedings of WMT 2012
//
template<typename Callback>
class Scope3Parser : public Parser<Callback>
{
public:
typedef Parser<Callback> Base;
typedef RuleTrieScope3 RuleTrie;
// TODO Make this configurable?
static bool RequiresCompressedChart() {
return false;
}
Scope3Parser(PChart &, const RuleTrie &, std::size_t);
~Scope3Parser();
void EnumerateHyperedges(const Range &, Callback &);
private:
void Init();
void InitRuleApplicationVector();
void FillSentenceMap(SentenceMap &);
void RecordPatternApplicationSpans(const PatternApplicationTrie &);
PatternApplicationTrie *m_patRoot;
std::vector<std::vector<bool> > m_quickCheckTable;
const RuleTrie &m_ruleTable;
const std::size_t m_maxChartSpan;
TailLattice m_lattice;
TailLatticeBuilder m_latticeBuilder;
SymbolRangeCalculator m_symbolRangeCalculator;
std::vector<SymbolRange> m_symbolRanges;
PatternApplicationKey m_patKey;
/* m_patSpans[i][j] records the set of all PAT nodes for span [i,i+j]
i.e. j is the width of the span */
std::vector<std::vector<
std::vector<const PatternApplicationTrie *> > > m_patSpans;
};
} // namespace S2T
} // namespace Syntax
} // namespace Moses
// Implementation
#include "Parser-inl.h"
|