File size: 1,480 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 |
#pragma once
#include "moses/Syntax/PHyperedge.h"
#include "moses/Syntax/PVertex.h"
#include "moses/Syntax/S2T/Parsers/Parser.h"
#include "moses/Syntax/S2T/RuleTrieCYKPlus.h"
#include "moses/Range.h"
namespace Moses
{
namespace Syntax
{
namespace S2T
{
// Parser that implements the recursive variant of CYK+ from this paper:
//
// Rico Sennrich
// "A CYK+ Variant for SCFG Decoding Without a Dot Chart"
// In proceedings of SSST-8 2014
//
template<typename Callback>
class RecursiveCYKPlusParser : public Parser<Callback>
{
public:
typedef Parser<Callback> Base;
typedef RuleTrieCYKPlus RuleTrie;
// TODO Make this configurable?
static bool RequiresCompressedChart() {
return true;
}
RecursiveCYKPlusParser(PChart &, const RuleTrie &, std::size_t);
~RecursiveCYKPlusParser() {}
void EnumerateHyperedges(const Range &, Callback &);
private:
void GetTerminalExtension(const RuleTrie::Node &, std::size_t, std::size_t);
void GetNonTerminalExtensions(const RuleTrie::Node &, std::size_t,
std::size_t, std::size_t);
void AddAndExtend(const RuleTrie::Node &, std::size_t, const PVertex &);
bool IsNonLexicalUnary(const PHyperedge &) const;
const RuleTrie &m_ruleTable;
const std::size_t m_maxChartSpan;
std::size_t m_maxEnd;
PHyperedge m_hyperedge;
Callback *m_callback;
};
} // namespace S2T
} // namespace Syntax
} // namespace Moses
// Implementation
#include "RecursiveCYKPlusParser-inl.h"
|