2010-07-18 03:23:09 +04:00
|
|
|
// $Id$
|
2010-04-12 14:15:49 +04:00
|
|
|
// vim:tabstop=2
|
|
|
|
/***********************************************************************
|
|
|
|
Moses - factored phrase-based language decoder
|
|
|
|
Copyright (C) 2010 Hieu Hoang
|
2011-02-24 15:36:50 +03:00
|
|
|
|
2010-04-12 14:15:49 +04:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2011-02-24 15:36:50 +03:00
|
|
|
|
2010-04-12 14:15:49 +04:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2011-02-24 15:36:50 +03:00
|
|
|
|
2010-04-12 14:15:49 +04:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
***********************************************************************/
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-06-27 19:13:15 +04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "RuleCube.h"
|
2010-10-01 01:10:25 +04:00
|
|
|
|
2011-06-27 19:13:15 +04:00
|
|
|
#include <queue>
|
|
|
|
#include <vector>
|
2010-10-01 01:10:25 +04:00
|
|
|
|
2011-06-27 19:13:15 +04:00
|
|
|
namespace Moses
|
2010-10-01 01:10:25 +04:00
|
|
|
{
|
|
|
|
|
2011-06-27 19:13:15 +04:00
|
|
|
class ChartManager;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2012-06-29 02:29:46 +04:00
|
|
|
/** Define an ordering between RuleCube based on their best item scores. This
|
|
|
|
* is used to order items in the priority queue.
|
|
|
|
*/
|
2011-06-27 19:13:15 +04:00
|
|
|
class RuleCubeOrderer
|
2010-04-08 21:16:10 +04:00
|
|
|
{
|
2013-05-29 21:16:15 +04:00
|
|
|
public:
|
2011-06-27 19:13:15 +04:00
|
|
|
bool operator()(const RuleCube *p, const RuleCube *q) const {
|
|
|
|
return p->GetTopScore() < q->GetTopScore();
|
2011-02-24 15:36:50 +03:00
|
|
|
}
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
|
|
|
|
2012-06-29 02:29:46 +04:00
|
|
|
/** @todo how is this used */
|
2011-03-11 19:28:36 +03:00
|
|
|
class RuleCubeQueue
|
2010-04-08 21:16:10 +04:00
|
|
|
{
|
2013-05-29 21:16:15 +04:00
|
|
|
public:
|
2011-06-27 19:13:15 +04:00
|
|
|
RuleCubeQueue(ChartManager &manager) : m_manager(manager) {}
|
2011-03-11 19:28:36 +03:00
|
|
|
~RuleCubeQueue();
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-06-27 19:13:15 +04:00
|
|
|
void Add(RuleCube *);
|
|
|
|
ChartHypothesis *Pop();
|
2013-05-29 21:16:15 +04:00
|
|
|
bool IsEmpty() const {
|
|
|
|
return m_queue.empty();
|
|
|
|
}
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
private:
|
2011-06-27 19:13:15 +04:00
|
|
|
typedef std::priority_queue<RuleCube*, std::vector<RuleCube*>,
|
2013-05-29 21:16:15 +04:00
|
|
|
RuleCubeOrderer > Queue;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-06-27 19:13:15 +04:00
|
|
|
Queue m_queue;
|
|
|
|
ChartManager &m_manager;
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
|
|
|
|
2011-06-27 19:13:15 +04:00
|
|
|
}
|