mosesdecoder/moses/ChartTranslationOptions.h

105 lines
3.3 KiB
C
Raw Normal View History

/***********************************************************************
Moses - factored phrase-based language decoder
Copyright (C) 2010 Hieu Hoang
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 "StackVec.h"
#include "TargetPhrase.h"
#include "TargetPhraseCollection.h"
#include "WordsRange.h"
#include <vector>
#include <boost/shared_ptr.hpp>
#include "ChartTranslationOption.h"
namespace Moses
{
class ChartTranslationOption;
class InputPath;
class InputType;
/** Similar to a DottedRule, but contains a direct reference to a list
2012-07-10 12:18:37 +04:00
* of translations and provdes an estimate of the best score. For a specific range in the input sentence
*/
2012-09-25 20:34:43 +04:00
class ChartTranslationOptions
{
friend std::ostream& operator<<(std::ostream&, const ChartTranslationOptions&);
2013-05-29 21:16:15 +04:00
public:
typedef std::vector<boost::shared_ptr<ChartTranslationOption> > CollType;
2012-07-10 12:18:37 +04:00
/** Constructor
\param targetPhraseColl @todo dunno
\param stackVec @todo dunno
\param wordsRange the range in the source sentence this translation option covers
\param score @todo dunno
*/
2012-09-25 20:34:43 +04:00
ChartTranslationOptions(const TargetPhraseCollection &targetPhraseColl,
2013-05-29 21:16:15 +04:00
const StackVec &stackVec,
const WordsRange &wordsRange,
float score);
~ChartTranslationOptions();
static float CalcEstimateOfBestScore(const TargetPhraseCollection &,
const StackVec &);
2014-01-15 19:42:02 +04:00
size_t GetSize() const {
return m_collection.size();
}
2013-12-12 00:03:30 +04:00
2012-07-10 12:18:37 +04:00
//! @todo dunno
2013-05-29 21:16:15 +04:00
const StackVec &GetStackVec() const {
return m_stackVec;
}
2012-07-10 12:18:37 +04:00
//! @todo isn't the translation suppose to just contain 1 target phrase, not a whole collection of them?
const CollType &GetTargetPhrases() const {
return m_collection;
}
2012-07-10 12:18:37 +04:00
//! the range in the source sentence this translation option covers
const WordsRange &GetSourceWordsRange() const {
return *m_wordsRange;
}
2012-07-10 12:18:37 +04:00
/** return an estimate of the best score possible with this translation option.
* the estimate is the sum of the top target phrase's estimated score plus the
* scores of the best child hypotheses.
*/
2013-05-29 21:16:15 +04:00
inline float GetEstimateOfBestScore() const {
return m_estimateOfBestScore;
}
2014-08-08 19:18:24 +04:00
void EvaluateWithSourceContext(const InputType &input, const InputPath &inputPath);
2013-09-22 18:15:00 +04:00
void SetInputPath(const InputPath *inputPath);
void CreateSourceRuleFromInputPath();
2013-05-29 21:16:15 +04:00
private:
2012-07-10 12:18:37 +04:00
StackVec m_stackVec; //! vector of hypothesis list!
CollType m_collection;
const WordsRange *m_wordsRange;
float m_estimateOfBestScore;
};
}