00001 #pragma once 00002 00003 #include <string> 00004 00005 #include <boost/functional/hash.hpp> 00006 00007 namespace MosesTraining 00008 { 00009 namespace Syntax 00010 { 00011 namespace PostprocessEgretForests 00012 { 00013 00014 struct Symbol { 00015 std::string value; 00016 bool isNonTerminal; 00017 }; 00018 00019 inline std::size_t hash_value(const Symbol &s) 00020 { 00021 std::size_t seed = 0; 00022 boost::hash_combine(seed, s.value); 00023 boost::hash_combine(seed, s.isNonTerminal); 00024 return seed; 00025 } 00026 00027 inline bool operator==(const Symbol &s, const Symbol &t) 00028 { 00029 return s.value == t.value && s.isNonTerminal == t.isNonTerminal; 00030 } 00031 00032 struct SymbolHasher { 00033 public: 00034 std::size_t operator()(const Symbol &s) const { 00035 return hash_value(s); 00036 } 00037 }; 00038 00039 struct SymbolEqualityPred { 00040 public: 00041 bool operator()(const Symbol &s, const Symbol &t) const { 00042 return s.value == t.value && s.isNonTerminal == t.isNonTerminal; 00043 } 00044 }; 00045 00046 } // namespace PostprocessEgretForests 00047 } // namespace Syntax 00048 } // namespace MosesTraining