1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
// $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
***********************************************************************/
#ifndef moses_DecodeStep_h
#define moses_DecodeStep_h
#include "util/check.hh"
#include "TypeDef.h"
#include "FactorTypeSet.h"
#include "Phrase.h"
namespace Moses
{
class DecodeFeature;
class PhraseDictionary;
class GenerationDictionary;
class TranslationOption;
class TranslationOptionCollection;
class PartialTranslOptColl;
class FactorCollection;
class InputType;
class FeatureFunction;
/** Specification for a decoding step.
* 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
* steps, both the DecodeType and a pointer to the Translation or Generation Feature
**/
class DecodeStep
{
protected:
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;
std::vector<FeatureFunction*> m_featuresToApply, m_featuresRemaining;
public:
DecodeStep(); //! not implemented
DecodeStep(const DecodeFeature *featurePtr,
const DecodeStep* prevDecodeStep,
const std::vector<FeatureFunction*> &features);
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();
}
const std::vector<FeatureFunction*> &GetFeaturesRemaining() const {
return m_featuresRemaining;
}
/*! 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 */
const PhraseDictionary* GetPhraseDictionaryFeature() const;
/*! returns generation table feature for generation step */
const GenerationDictionary* GetGenerationDictionaryFeature() const;
/*! Given an input TranslationOption, extend it in some way (put results in outputPartialTranslOptColl) */
virtual void Process(const TranslationOption &inputPartialTranslOpt
, const DecodeStep &decodeStep
, PartialTranslOptColl &outputPartialTranslOptColl
, TranslationOptionCollection *toc
, bool adhereTableLimit
, const Phrase &src) const = 0;
void RemoveFeature(const FeatureFunction *ff);
};
}
#endif
|