2010-07-18 03:23:09 +04:00
|
|
|
// $Id$
|
2010-04-12 14:15:49 +04:00
|
|
|
/***********************************************************************
|
|
|
|
Moses - factored phrase-based language decoder
|
|
|
|
Copyright (C) 2010 Hieu Hoang
|
2011-02-24 16:14:42 +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 16:14:42 +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 16:14:42 +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 <cassert>
|
|
|
|
#include <vector>
|
|
|
|
#include "Word.h"
|
|
|
|
#include "WordsRange.h"
|
|
|
|
#include "TargetPhrase.h"
|
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
2011-03-11 19:28:36 +03:00
|
|
|
class CoveredChartSpan;
|
2011-04-05 00:43:02 +04:00
|
|
|
class ChartCellCollection;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
// basically a phrase translation and the vector of words consumed to map each word
|
2010-09-23 21:39:32 +04:00
|
|
|
class ChartTranslationOption
|
2010-04-08 21:16:10 +04:00
|
|
|
{
|
2011-02-24 16:14:42 +03:00
|
|
|
friend std::ostream& operator<<(std::ostream&, const ChartTranslationOption&);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
protected:
|
2011-03-11 19:28:36 +03:00
|
|
|
const TargetPhrase &m_targetPhrase;
|
|
|
|
const CoveredChartSpan &m_lastCoveredChartSpan;
|
2011-02-24 16:14:42 +03:00
|
|
|
/* map each source word in the phrase table to:
|
|
|
|
1. a word in the input sentence, if the pt word is a terminal
|
|
|
|
2. a 1+ phrase in the input sentence, if the pt word is a non-terminal
|
|
|
|
*/
|
|
|
|
const WordsRange &m_wordsRange;
|
|
|
|
|
2011-04-05 00:43:02 +04:00
|
|
|
float m_estimateOfBestScore;
|
|
|
|
|
|
|
|
ChartTranslationOption &operator=(const ChartTranslationOption &); // not implemented
|
|
|
|
|
|
|
|
void CalcEstimateOfBestScore(const CoveredChartSpan *, const ChartCellCollection &);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
public:
|
2011-04-05 00:43:02 +04:00
|
|
|
ChartTranslationOption(const TargetPhrase &targetPhrase, const CoveredChartSpan &lastCoveredChartSpan, const WordsRange &wordsRange, const ChartCellCollection &allChartCells)
|
2011-02-24 16:14:42 +03:00
|
|
|
:m_targetPhrase(targetPhrase)
|
2011-03-11 19:28:36 +03:00
|
|
|
,m_lastCoveredChartSpan(lastCoveredChartSpan)
|
2011-02-24 16:14:42 +03:00
|
|
|
,m_wordsRange(wordsRange)
|
2011-04-05 00:43:02 +04:00
|
|
|
,m_estimateOfBestScore(m_targetPhrase.GetFutureScore())
|
|
|
|
{
|
|
|
|
CalcEstimateOfBestScore(&m_lastCoveredChartSpan, allChartCells);
|
|
|
|
}
|
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
~ChartTranslationOption()
|
|
|
|
{}
|
|
|
|
|
|
|
|
const TargetPhrase &GetTargetPhrase() const {
|
|
|
|
return m_targetPhrase;
|
|
|
|
}
|
|
|
|
|
2011-03-11 19:28:36 +03:00
|
|
|
const CoveredChartSpan &GetLastCoveredChartSpan() const {
|
|
|
|
return m_lastCoveredChartSpan;
|
2011-02-24 16:14:42 +03:00
|
|
|
}
|
|
|
|
|
2011-03-11 19:28:36 +03:00
|
|
|
const WordsRange &GetSourceWordsRange() const {
|
2011-02-24 16:14:42 +03:00
|
|
|
return m_wordsRange;
|
|
|
|
}
|
|
|
|
|
2011-04-05 00:43:02 +04:00
|
|
|
// return an estimate of the best score possible with this translation option.
|
|
|
|
// the estimate is the sum of the target phrase's estimated score plus the
|
|
|
|
// scores of the best child hypotheses. (the same as the ordering criterion
|
|
|
|
// currently used in RuleCubeQueue.)
|
|
|
|
inline float GetEstimateOfBestScore() const {
|
|
|
|
return m_estimateOfBestScore;
|
2011-02-24 16:14:42 +03:00
|
|
|
}
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|