mosesdecoder/moses/ChartCellLabel.h

87 lines
2.4 KiB
C
Raw Normal View History

/***********************************************************************
Moses - statistical machine translation system
Copyright (C) 2006-2011 University of Edinburgh
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.
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.
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
***********************************************************************/
#pragma once
#include "HypoList.h"
#include "Word.h"
#include "WordsRange.h"
2013-05-29 21:16:15 +04:00
namespace search
{
class Vertex;
}
2012-10-08 00:48:15 +04:00
namespace Moses
{
class Word;
2012-07-03 21:11:53 +04:00
/** Contains a range, word (non-terms?) and a vector of hypotheses.
2013-05-29 21:16:15 +04:00
* @todo This is probably incompatible with lattice decoding when the word that spans
* a position (or positions) can vary.
* @todo is this to hold sorted hypotheses that are in the queue for creating the next hypos?
*/
class ChartCellLabel
{
2013-05-29 21:16:15 +04:00
public:
2012-10-08 00:48:15 +04:00
union Stack {
const HypoList *cube; // cube pruning
2013-05-29 21:16:15 +04:00
search::Vertex *incr; // incremental search after filling.
void *incr_generator; // incremental search during filling.
2012-10-08 00:48:15 +04:00
};
ChartCellLabel(const WordsRange &coverage, const Word &label,
2012-10-08 00:48:15 +04:00
Stack stack=Stack())
: m_coverage(coverage)
, m_label(label)
, m_stack(stack)
{}
2013-05-29 21:16:15 +04:00
const WordsRange &GetCoverage() const {
return m_coverage;
}
const Word &GetLabel() const {
return m_label;
}
Stack GetStack() const {
return m_stack;
}
Stack &MutableStack() {
return m_stack;
}
2013-05-29 21:16:15 +04:00
bool operator<(const ChartCellLabel &other) const {
// m_coverage and m_label uniquely identify a ChartCellLabel, so don't
// need to compare m_stack.
if (m_coverage == other.m_coverage) {
return m_label < other.m_label;
}
return m_coverage < other.m_coverage;
}
2013-05-29 21:16:15 +04:00
private:
const WordsRange &m_coverage;
const Word &m_label;
2012-10-08 00:48:15 +04:00
Stack m_stack;
};
}