mosesdecoder/phrase-extract/postprocess-egret-forests/Symbol.h
Phil Williams 9e88f794e6 Add phrase-extract/postprocess-egret-forests
This performs some minor transformations to Egret forests: escaping of
Moses special characters; removal of "^g" suffixes from constituent labels;
and marking of slash/hyphen split points (using @ characters).
2015-03-10 13:51:30 +00:00

49 lines
902 B
C++

#pragma once
#include <string>
#include <boost/functional/hash.hpp>
namespace MosesTraining
{
namespace Syntax
{
namespace PostprocessEgretForests
{
struct Symbol {
std::string value;
bool isNonTerminal;
};
inline std::size_t hash_value(const Symbol &s)
{
std::size_t seed = 0;
boost::hash_combine(seed, s.value);
boost::hash_combine(seed, s.isNonTerminal);
return seed;
}
inline bool operator==(const Symbol &s, const Symbol &t)
{
return s.value == t.value && s.isNonTerminal == t.isNonTerminal;
}
struct SymbolHasher {
public:
std::size_t operator()(const Symbol &s) const {
return hash_value(s);
}
};
struct SymbolEqualityPred {
public:
bool operator()(const Symbol &s, const Symbol &t) const {
return s.value == t.value && s.isNonTerminal == t.isNonTerminal;
}
};
} // namespace PostprocessEgretForests
} // namespace Syntax
} // namespace MosesTraining