00001 #pragma once
00002
00003 #include <stack>
00004 #include <vector>
00005
00006 #include "util/string_piece.hh"
00007
00008 #include "moses/FactorCollection.h"
00009 #include "moses/TypeDef.h"
00010
00011 #include "HyperPath.h"
00012 #include "TreeFragmentTokenizer.h"
00013
00014 namespace Moses
00015 {
00016 namespace Syntax
00017 {
00018 namespace F2S
00019 {
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 class HyperPathLoader
00031 {
00032 public:
00033 void Load(const StringPiece &, HyperPath &);
00034
00035 private:
00036 struct NodeTuple {
00037 int index;
00038 int parent;
00039 int depth;
00040 std::size_t symbol;
00041
00042 };
00043
00044
00045 int DetermineHeight() const;
00046
00047
00048
00049 void GenerateNodeTupleSeq(int height);
00050
00051 const Factor *AddTerminalFactor(const StringPiece &s) {
00052 return FactorCollection::Instance().AddFactor(s, false);
00053 }
00054
00055 const Factor *AddNonTerminalFactor(const StringPiece &s) {
00056 return FactorCollection::Instance().AddFactor(s, true);
00057 }
00058
00059 std::vector<TreeFragmentToken> m_tokenSeq;
00060 std::vector<NodeTuple> m_nodeTupleSeq;
00061 std::stack<int> m_parentStack;
00062 };
00063
00064 }
00065 }
00066 }