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
|
|
|
|
|
2012-01-25 16:26:28 +04:00
|
|
|
#include "StackVec.h"
|
2011-06-27 19:13:15 +04:00
|
|
|
#include "TargetPhrase.h"
|
|
|
|
#include "TargetPhraseCollection.h"
|
|
|
|
#include "WordsRange.h"
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
#include <vector>
|
2013-08-09 21:16:31 +04:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2013-08-12 22:01:06 +04:00
|
|
|
#include "ChartTranslationOption.h"
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
2013-08-12 22:01:06 +04:00
|
|
|
class ChartTranslationOption;
|
2013-08-13 15:12:58 +04:00
|
|
|
class InputPath;
|
|
|
|
class InputType;
|
2013-08-12 13:34:45 +04:00
|
|
|
|
2012-06-27 03:45:02 +04:00
|
|
|
/** 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-06-27 03:45:02 +04:00
|
|
|
*/
|
2012-09-25 20:34:43 +04:00
|
|
|
class ChartTranslationOptions
|
2010-04-08 21:16:10 +04:00
|
|
|
{
|
2013-12-11 23:19:25 +04:00
|
|
|
friend std::ostream& operator<<(std::ostream&, const ChartTranslationOptions&);
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
public:
|
2013-08-12 13:34:45 +04:00
|
|
|
typedef std::vector<boost::shared_ptr<ChartTranslationOption> > CollType;
|
2013-08-09 21:16:31 +04:00
|
|
|
|
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,
|
2013-08-09 13:27:46 +04:00
|
|
|
float score);
|
|
|
|
~ChartTranslationOptions();
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2012-02-07 03:54:01 +04:00
|
|
|
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;
|
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
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?
|
2013-08-09 21:16:31 +04:00
|
|
|
const CollType &GetTargetPhrases() const {
|
2013-08-13 15:12:58 +04:00
|
|
|
return m_collection;
|
2011-06-27 19:13:15 +04:00
|
|
|
}
|
|
|
|
|
2012-07-10 12:18:37 +04:00
|
|
|
//! the range in the source sentence this translation option covers
|
2011-03-11 19:28:36 +03:00
|
|
|
const WordsRange &GetSourceWordsRange() const {
|
2012-02-07 03:54:01 +04:00
|
|
|
return *m_wordsRange;
|
2011-02-24 16:14:42 +03:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2011-06-27 19:13:15 +04:00
|
|
|
|
2014-08-08 19:18:24 +04:00
|
|
|
void EvaluateWithSourceContext(const InputType &input, const InputPath &inputPath);
|
2013-08-13 15:12:58 +04:00
|
|
|
|
2013-09-22 18:15:00 +04:00
|
|
|
void SetInputPath(const InputPath *inputPath);
|
|
|
|
|
|
|
|
void CreateSourceRuleFromInputPath();
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
private:
|
2011-06-27 19:13:15 +04:00
|
|
|
|
2012-07-10 12:18:37 +04:00
|
|
|
StackVec m_stackVec; //! vector of hypothesis list!
|
2013-08-13 15:12:58 +04:00
|
|
|
CollType m_collection;
|
2013-08-09 21:16:31 +04:00
|
|
|
|
2012-02-07 03:54:01 +04:00
|
|
|
const WordsRange *m_wordsRange;
|
2011-06-27 19:13:15 +04:00
|
|
|
float m_estimateOfBestScore;
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|