2008-06-11 14:52:57 +04:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
Moses - factored phrase-based language decoder
|
|
|
|
Copyright (C) 2006 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
|
|
|
|
***********************************************************************/
|
|
|
|
|
2010-02-24 14:15:44 +03:00
|
|
|
#ifndef moses_DecodeStep_h
|
|
|
|
#define moses_DecodeStep_h
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-11-18 16:07:41 +04:00
|
|
|
#include "util/check.hh"
|
2008-06-11 14:52:57 +04:00
|
|
|
#include "TypeDef.h"
|
2013-02-06 15:29:54 +04:00
|
|
|
#include "FactorTypeSet.h"
|
2013-05-28 04:25:27 +04:00
|
|
|
#include "Phrase.h"
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2010-08-10 17:12:00 +04:00
|
|
|
class DecodeFeature;
|
2013-02-22 23:17:57 +04:00
|
|
|
class PhraseDictionary;
|
2008-06-11 14:52:57 +04:00
|
|
|
class GenerationDictionary;
|
|
|
|
class TranslationOption;
|
|
|
|
class TranslationOptionCollection;
|
|
|
|
class PartialTranslOptColl;
|
|
|
|
class FactorCollection;
|
|
|
|
class InputType;
|
|
|
|
|
2012-06-27 03:45:02 +04:00
|
|
|
/** Specification for a decoding step.
|
2008-06-11 14:52:57 +04:00
|
|
|
* The factored translation model consists of Translation and Generation
|
|
|
|
* steps, which consult a Dictionary of phrase translations or word
|
|
|
|
* generations. This class implements the specification for one of these
|
2010-08-10 17:12:00 +04:00
|
|
|
* steps, both the DecodeType and a pointer to the Translation or Generation Feature
|
2008-06-11 14:52:57 +04:00
|
|
|
**/
|
2011-02-24 16:14:42 +03:00
|
|
|
class DecodeStep
|
2008-06-11 14:52:57 +04:00
|
|
|
{
|
|
|
|
protected:
|
2011-02-24 16:14:42 +03:00
|
|
|
FactorMask m_outputFactors; //! mask of what factors exist on the output side after this decode step
|
|
|
|
std::vector<FactorType> m_conflictFactors; //! list of the factors that may conflict during this step
|
|
|
|
std::vector<FactorType> m_newOutputFactors; //! list of the factors that are new in this step, may be empty
|
|
|
|
const DecodeFeature* m_decodeFeature;
|
2008-06-11 14:52:57 +04:00
|
|
|
|
|
|
|
public:
|
2011-02-24 16:14:42 +03:00
|
|
|
DecodeStep(); //! not implemented
|
|
|
|
DecodeStep(const DecodeFeature *featurePtr, const DecodeStep* prevDecodeStep);
|
|
|
|
virtual ~DecodeStep();
|
|
|
|
|
|
|
|
//! mask of factors that are present after this decode step
|
|
|
|
const FactorMask& GetOutputFactorMask() const {
|
|
|
|
return m_outputFactors;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! returns true if this decode step must match some pre-existing factors
|
|
|
|
bool IsFilteringStep() const {
|
|
|
|
return !m_conflictFactors.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! returns true if this decode step produces one or more new factors
|
|
|
|
bool IsFactorProducingStep() const {
|
|
|
|
return !m_newOutputFactors.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! returns a list (possibly empty) of the (target side) factors that
|
|
|
|
* are produced in this decoding step. For example, if a previous step
|
|
|
|
* generated factor 1, and this step generates 1,2, then only 2 will be
|
|
|
|
* in the returned vector. */
|
|
|
|
const std::vector<FactorType>& GetNewOutputFactors() const {
|
|
|
|
return m_newOutputFactors;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! returns a list (possibly empty) of the (target side) factors that
|
|
|
|
* are produced BUT ALREADY EXIST and therefore must be checked for
|
|
|
|
* conflict or compatibility */
|
|
|
|
const std::vector<FactorType>& GetConflictFactors() const {
|
|
|
|
return m_conflictFactors;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! returns phrase table feature for translation step */
|
2013-02-22 23:17:57 +04:00
|
|
|
const PhraseDictionary* GetPhraseDictionaryFeature() const;
|
2011-02-24 16:14:42 +03:00
|
|
|
|
|
|
|
/*! returns generation table feature for generation step */
|
|
|
|
const GenerationDictionary* GetGenerationDictionaryFeature() const;
|
|
|
|
|
|
|
|
|
|
|
|
/*! Given an input TranslationOption, extend it in some way (put results in outputPartialTranslOptColl) */
|
2013-05-11 17:13:26 +04:00
|
|
|
virtual void Process(const TranslationOption &inputPartialTranslOpt
|
2011-02-24 16:14:42 +03:00
|
|
|
, const DecodeStep &decodeStep
|
|
|
|
, PartialTranslOptColl &outputPartialTranslOptColl
|
|
|
|
, TranslationOptionCollection *toc
|
2013-05-28 04:25:27 +04:00
|
|
|
, bool adhereTableLimit
|
|
|
|
, const Phrase &src) const = 0;
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
};
|
2008-10-09 03:51:26 +04:00
|
|
|
|
|
|
|
}
|
2010-02-24 14:15:44 +03:00
|
|
|
#endif
|