2015-03-10 16:51:30 +03:00
|
|
|
#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
|
|
|
|
{
|
2015-05-02 13:45:24 +03:00
|
|
|
public:
|
2015-03-10 16:51:30 +03:00
|
|
|
void Sort(const Forest &, std::vector<const Forest::Vertex *> &);
|
|
|
|
|
2015-05-02 13:45:24 +03:00
|
|
|
private:
|
2015-03-10 16:51:30 +03:00
|
|
|
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
|