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
|
|
|
|
|
|
|
#include "ChartCellCollection.h"
|
2011-03-11 16:08:43 +03:00
|
|
|
#include "InputType.h"
|
|
|
|
#include "WordsRange.h"
|
2015-04-27 21:41:47 +03:00
|
|
|
#include "ChartManager.h"
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2012-10-02 19:34:25 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
ChartCellCollectionBase::~ChartCellCollectionBase()
|
|
|
|
{
|
2012-10-02 19:34:25 +04:00
|
|
|
m_source.clear();
|
2013-05-29 21:16:15 +04:00
|
|
|
for (std::vector<std::vector<ChartCellBase*> >::iterator i = m_cells.begin(); i != m_cells.end(); ++i)
|
2012-10-02 19:34:25 +04:00
|
|
|
RemoveAllInColl(*i);
|
|
|
|
}
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
class CubeCellFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit CubeCellFactory(ChartManager &manager) : m_manager(manager) {}
|
2012-10-02 19:34:25 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
ChartCell *operator()(size_t start, size_t end) const {
|
|
|
|
return new ChartCell(start, end, m_manager);
|
|
|
|
}
|
2012-10-02 19:34:25 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
private:
|
|
|
|
ChartManager &m_manager;
|
2012-10-02 19:34:25 +04:00
|
|
|
};
|
|
|
|
|
2012-07-02 23:01:07 +04:00
|
|
|
/** Costructor
|
|
|
|
\param input the input sentence
|
|
|
|
\param manager reference back to the manager
|
|
|
|
*/
|
2011-03-11 19:28:36 +03:00
|
|
|
ChartCellCollection::ChartCellCollection(const InputType &input, ChartManager &manager)
|
2015-04-27 21:41:47 +03:00
|
|
|
:ChartCellCollectionBase(input, CubeCellFactory(manager), manager.GetParser()) {}
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|