#pragma once #include #include #include #include #include "SHyperedge.h" #include "SHyperedgeBundle.h" namespace Moses { namespace Syntax { // A cube -- in the cube pruning sense (see Chiang (2007)) -- that lazily // produces SHyperedge objects from a SHyperedgeBundle in approximately // best-first order. class Cube { public: Cube(const SHyperedgeBundle &); ~Cube(); SHyperedge *Pop(); SHyperedge *Top() const { return m_queue.top().first; } bool IsEmpty() const { return m_queue.empty(); } private: typedef boost::unordered_set > CoordinateSet; typedef std::pair *> QueueItem; class QueueItemOrderer { public: bool operator()(const QueueItem &p, const QueueItem &q) const { return p.first->label.futureScore < q.first->label.futureScore; } }; typedef std::priority_queue, QueueItemOrderer> Queue; SHyperedge *CreateHyperedge(const std::vector &); void CreateNeighbour(const std::vector &); void CreateNeighbours(const std::vector &); const SHyperedgeBundle &m_bundle; CoordinateSet m_visited; Queue m_queue; }; } // Syntax } // Moses