|
#pragma once |
|
|
|
#include <stack> |
|
#include <vector> |
|
|
|
#include "util/string_piece.hh" |
|
|
|
#include "moses/FactorCollection.h" |
|
#include "moses/TypeDef.h" |
|
|
|
#include "HyperPath.h" |
|
#include "TreeFragmentTokenizer.h" |
|
|
|
namespace Moses |
|
{ |
|
namespace Syntax |
|
{ |
|
namespace F2S |
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HyperPathLoader |
|
{ |
|
public: |
|
void Load(const StringPiece &, HyperPath &); |
|
|
|
private: |
|
struct NodeTuple { |
|
int index; |
|
int parent; |
|
int depth; |
|
std::size_t symbol; |
|
|
|
}; |
|
|
|
|
|
int DetermineHeight() const; |
|
|
|
|
|
|
|
void GenerateNodeTupleSeq(int height); |
|
|
|
const Factor *AddTerminalFactor(const StringPiece &s) { |
|
return FactorCollection::Instance().AddFactor(s, false); |
|
} |
|
|
|
const Factor *AddNonTerminalFactor(const StringPiece &s) { |
|
return FactorCollection::Instance().AddFactor(s, true); |
|
} |
|
|
|
std::vector<TreeFragmentToken> m_tokenSeq; |
|
std::vector<NodeTuple> m_nodeTupleSeq; |
|
std::stack<int> m_parentStack; |
|
}; |
|
|
|
} |
|
} |
|
} |
|
|