/* * Misc.h * * Created on: 2 Jun 2016 * Author: hieu */ #pragma once #include #include #include #include "../HypothesisColl.h" #include "../Vector.h" #include "Hypothesis.h" namespace Moses2 { namespace SCFG { class SymbolBind; class TargetPhrases; class Queue; /////////////////////////////////////////// class SeenPosition { public: const SymbolBind &symbolBind; const SCFG::TargetPhrases &tps; size_t tpInd; Vector hypoIndColl; SeenPosition(MemPool &pool, const SymbolBind &vSymbolBind, const SCFG::TargetPhrases &vtps, size_t numNT); SeenPosition(MemPool &pool, const SymbolBind &vSymbolBind, const SCFG::TargetPhrases &vtps, size_t vtpInd, const Vector &vhypoIndColl); bool operator==(const SeenPosition &compare) const; size_t hash() const; std::string Debug(const System &system) const; }; /////////////////////////////////////////// class SeenPositions { public: bool Add(const SeenPosition *item); void clear() { m_coll.clear(); } protected: typedef boost::unordered_set, UnorderedComparer > Coll; Coll m_coll; }; /////////////////////////////////////////// class QueueItem { public: SCFG::Hypothesis *hypo; static QueueItem *Create(MemPool &pool, SCFG::Manager &mgr); void Init( MemPool &pool, const SymbolBind &symbolBind, const SCFG::TargetPhrases &tps, const Vector &hypoIndColl); void Init( MemPool &pool, const SymbolBind &symbolBind, const SCFG::TargetPhrases &tps, size_t vTPInd, const Vector &hypoIndColl); void AddHypos(const Moses2::Hypotheses &hypos); void CreateHypo( MemPool &systemPool, SCFG::Manager &mgr, const SCFG::InputPath &path, const SCFG::SymbolBind &symbolBind); void CreateNext( MemPool &systemPool, MemPool &mgrPool, SCFG::Manager &mgr, SCFG::Queue &queue, SeenPositions &seenPositions, const SCFG::InputPath &path); std::string Debug(const System &system) const; protected: typedef Vector HyposColl; HyposColl *m_hyposColl; const SymbolBind *symbolBind; const SCFG::TargetPhrases *tps; size_t tpInd; const Vector *m_hypoIndColl; // pointer to variable in seen position // hypos and ind to the 1 we're using QueueItem(MemPool &pool); }; /////////////////////////////////////////// typedef std::deque QueueItemRecycler; /////////////////////////////////////////// class QueueItemOrderer { public: bool operator()(QueueItem* itemA, QueueItem* itemB) const { HypothesisFutureScoreOrderer orderer; return !orderer(itemA->hypo, itemB->hypo); } }; /////////////////////////////////////////// class Queue : public std::priority_queue, QueueItemOrderer> { }; } }