00001 #pragma once 00002 #ifndef EXTRACT_GHKM_RULE_H_ 00003 #define EXTRACT_GHKM_RULE_H_ 00004 00005 #include <string> 00006 #include <vector> 00007 00008 #include "Alignment.h" 00009 00010 namespace MosesTraining 00011 { 00012 namespace Syntax 00013 { 00014 namespace GHKM 00015 { 00016 00017 class Node; 00018 00019 enum SymbolType { Terminal, NonTerminal }; 00020 00021 class Symbol 00022 { 00023 public: 00024 Symbol(const std::string &v, SymbolType t) : m_value(v) , m_type(t) {} 00025 00026 const std::string &GetValue() const { 00027 return m_value; 00028 } 00029 SymbolType GetType() const { 00030 return m_type; 00031 } 00032 00033 private: 00034 std::string m_value; 00035 SymbolType m_type; 00036 }; 00037 00038 // Base class for ScfgRule and StsgRule. 00039 class Rule 00040 { 00041 public: 00042 virtual ~Rule() {} 00043 00044 const Alignment &GetAlignment() const { 00045 return m_alignment; 00046 } 00047 00048 virtual int Scope() const = 0; 00049 00050 protected: 00051 static bool PartitionOrderComp(const Node *, const Node *); 00052 00053 static int Scope(const std::vector<Symbol>&); 00054 00055 Alignment m_alignment; 00056 }; 00057 00058 } // namespace GHKM 00059 } // namespace Syntax 00060 } // namespace MosesTraining 00061 00062 #endif