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
|
|
|
|
|
|
|
#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;
|
2013-05-30 14:25:57 +04:00
|
|
|
class FeatureFunction;
|
2013-12-05 17:06:35 +04:00
|
|
|
class DecodeGraph;
|
2008-06-11 14:52:57 +04:00
|
|
|
|
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;
|
2013-12-05 17:06:35 +04:00
|
|
|
const DecodeGraph *m_container;
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2013-05-30 14:25:57 +04:00
|
|
|
std::vector<FeatureFunction*> m_featuresToApply, m_featuresRemaining;
|
2008-06-11 14:52:57 +04:00
|
|
|
public:
|
2011-02-24 16:14:42 +03:00
|
|
|
DecodeStep(); //! not implemented
|
2013-12-05 17:06:35 +04:00
|
|
|
DecodeStep(DecodeFeature *featurePtr,
|
2013-05-30 15:51:40 +04:00
|
|
|
const DecodeStep* prevDecodeStep,
|
|
|
|
const std::vector<FeatureFunction*> &features);
|
2011-02-24 16:14:42 +03:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-05-30 15:51:40 +04:00
|
|
|
const std::vector<FeatureFunction*> &GetFeaturesRemaining() const {
|
|
|
|
return m_featuresRemaining;
|
|
|
|
}
|
2013-05-30 14:25:57 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
/*! 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;
|
|
|
|
|
2013-05-30 23:04:48 +04:00
|
|
|
void RemoveFeature(const FeatureFunction *ff);
|
|
|
|
|
2013-12-05 17:06:35 +04:00
|
|
|
void SetContainer(const DecodeGraph *container)
|
|
|
|
{ m_container = container; }
|
|
|
|
const DecodeGraph *GetContainer() const
|
|
|
|
{ return m_container; }
|
|
|
|
|
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
|