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
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <queue>
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2011-03-11 16:08:43 +03:00
|
|
|
#include "Word.h"
|
|
|
|
#include "WordsRange.h"
|
|
|
|
#include "NonTerminal.h"
|
2010-04-08 21:16:10 +04:00
|
|
|
#include "ChartHypothesis.h"
|
|
|
|
#include "ChartHypothesisCollection.h"
|
|
|
|
#include "QueueEntry.h"
|
|
|
|
|
2010-09-23 20:32:44 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2011-02-24 15:36:50 +03:00
|
|
|
class ChartTranslationOptionList;
|
2011-03-11 16:08:43 +03:00
|
|
|
class ChartTranslationOptionCollection;
|
2010-04-08 21:16:10 +04:00
|
|
|
class ChartCellCollection;
|
2011-03-11 16:08:43 +03:00
|
|
|
class ChartManager;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
class ChartCell
|
|
|
|
{
|
2011-02-24 15:36:50 +03:00
|
|
|
friend std::ostream& operator<<(std::ostream&, const ChartCell&);
|
2010-04-08 21:16:10 +04:00
|
|
|
public:
|
|
|
|
|
|
|
|
protected:
|
2011-03-11 16:08:43 +03:00
|
|
|
std::map<Moses::Word, ChartHypothesisCollection> m_hypoColl;
|
|
|
|
Moses::NonTerminalSet m_constituentLabelSet;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 15:36:50 +03:00
|
|
|
Moses::WordsRange m_coverage;
|
|
|
|
|
|
|
|
bool m_nBestIsEnabled; /**< flag to determine whether to keep track of old arcs */
|
2011-03-11 16:08:43 +03:00
|
|
|
ChartManager &m_manager;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
public:
|
2011-03-11 16:08:43 +03:00
|
|
|
ChartCell(size_t startPos, size_t endPos, ChartManager &manager);
|
2011-02-24 15:36:50 +03:00
|
|
|
|
|
|
|
void ProcessSentence(const Moses::ChartTranslationOptionList &transOptList
|
|
|
|
,const ChartCellCollection &allChartCells);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-03-11 16:08:43 +03:00
|
|
|
const HypoList &GetSortedHypotheses(const Moses::Word &constituentLabel) const;
|
|
|
|
bool AddHypothesis(ChartHypothesis *hypo);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 15:36:50 +03:00
|
|
|
void SortHypotheses();
|
|
|
|
void PruneToSize();
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-03-11 16:08:43 +03:00
|
|
|
const ChartHypothesis *GetBestHypothesis() const;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-03-11 16:08:43 +03:00
|
|
|
bool ConstituentLabelExists(const Moses::Word &constituentLabel) const;
|
|
|
|
const Moses::NonTerminalSet &GetConstituentLabelSet() const {
|
|
|
|
return m_constituentLabelSet;
|
2011-02-24 15:36:50 +03:00
|
|
|
}
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 15:36:50 +03:00
|
|
|
void CleanupArcList();
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 15:36:50 +03:00
|
|
|
void OutputSizes(std::ostream &out) const;
|
|
|
|
size_t GetSize() const;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 15:36:50 +03:00
|
|
|
//! transitive comparison used for adding objects into set
|
|
|
|
inline bool operator<(const ChartCell &compare) const {
|
|
|
|
return m_coverage < compare.m_coverage;
|
|
|
|
}
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 15:36:50 +03:00
|
|
|
void GetSearchGraph(long translationId, std::ostream &outputSearchGraphStream) const;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|