mosesdecoder/moses/ChartCellLabel.h

90 lines
2.4 KiB
C
Raw Permalink 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"
2015-10-25 16:37:59 +03:00
#include "Range.h"
2014-03-26 15:23:23 +04:00
#include "ChartParserCallback.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
};
2015-10-25 16:37:59 +03:00
ChartCellLabel(const Range &coverage, const Word &label,
2012-10-08 00:48:15 +04:00
Stack stack=Stack())
: m_coverage(coverage)
, m_label(label)
2014-03-26 15:23:23 +04:00
, m_stack(stack)
, m_bestScore(0) {
}
2015-10-25 16:37:59 +03:00
const Range &GetCoverage() const {
2013-05-29 21:16:15 +04:00
return m_coverage;
}
const Word &GetLabel() const {
return m_label;
}
Stack GetStack() const {
return m_stack;
}
Stack &MutableStack() {
return m_stack;
}
2014-03-26 15:23:23 +04:00
//caching of best score on stack
float GetBestScore(const ChartParserCallback *outColl) const {
if (m_bestScore == 0) {
m_bestScore = outColl->GetBestScore(this);
}
return m_bestScore;
}
2013-05-29 21:16:15 +04:00
private:
2015-10-25 16:37:59 +03:00
const Range &m_coverage;
const Word &m_label;
2014-06-16 03:55:36 +04:00
//const InputPath &m_inputPath;
2012-10-08 00:48:15 +04:00
Stack m_stack;
2014-03-26 15:23:23 +04:00
mutable float m_bestScore;
};
}