mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-29 06:52:34 +03:00
9e88f794e6
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).
35 lines
729 B
C++
35 lines
729 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include <boost/unordered_map.hpp>
|
|
#include <boost/unordered_set.hpp>
|
|
|
|
#include "Forest.h"
|
|
|
|
namespace MosesTraining
|
|
{
|
|
namespace Syntax
|
|
{
|
|
namespace PostprocessEgretForests
|
|
{
|
|
|
|
class TopologicalSorter
|
|
{
|
|
public:
|
|
void Sort(const Forest &, std::vector<const Forest::Vertex *> &);
|
|
|
|
private:
|
|
typedef boost::unordered_set<const Forest::Vertex *> VertexSet;
|
|
|
|
void BuildPredSets(const Forest &);
|
|
void Visit(const Forest::Vertex &, std::vector<const Forest::Vertex *> &);
|
|
|
|
boost::unordered_set<const Forest::Vertex *> m_visited;
|
|
boost::unordered_map<const Forest::Vertex *, VertexSet> m_predSets;
|
|
};
|
|
|
|
} // namespace PostprocessEgretForests
|
|
} // namespace Syntax
|
|
} // namespace MosesTraining
|