mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-08 04:27:53 +03:00
create blank states
This commit is contained in:
parent
31ae7d6f50
commit
d9cd216ceb
@ -41,7 +41,12 @@ Distortion::~Distortion() {
|
|||||||
// TODO Auto-generated destructor stub
|
// TODO Auto-generated destructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
const Moses::FFState* Distortion::EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const
|
Moses::FFState* Distortion::BlankState(const Manager &mgr, const PhraseImpl &input) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Moses::FFState* Distortion::EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const
|
||||||
{
|
{
|
||||||
MemPool &pool = mgr.GetPool();
|
MemPool &pool = mgr.GetPool();
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ public:
|
|||||||
Distortion(size_t startInd, const std::string &line);
|
Distortion(size_t startInd, const std::string &line);
|
||||||
virtual ~Distortion();
|
virtual ~Distortion();
|
||||||
|
|
||||||
virtual const Moses::FFState* EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const;
|
virtual Moses::FFState* BlankState(const Manager &mgr, const PhraseImpl &input) const;
|
||||||
|
virtual Moses::FFState* EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const;
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
EvaluateInIsolation(const System &system,
|
EvaluateInIsolation(const System &system,
|
||||||
|
@ -36,7 +36,12 @@ SkeletonStatefulFF::~SkeletonStatefulFF() {
|
|||||||
// TODO Auto-generated destructor stub
|
// TODO Auto-generated destructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
const Moses::FFState* SkeletonStatefulFF::EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const
|
Moses::FFState* SkeletonStatefulFF::BlankState(const Manager &mgr, const PhraseImpl &input) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Moses::FFState* SkeletonStatefulFF::EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const
|
||||||
{
|
{
|
||||||
return new SkeletonState(0);
|
return new SkeletonState(0);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@ public:
|
|||||||
SkeletonStatefulFF(size_t startInd, const std::string &line);
|
SkeletonStatefulFF(size_t startInd, const std::string &line);
|
||||||
virtual ~SkeletonStatefulFF();
|
virtual ~SkeletonStatefulFF();
|
||||||
|
|
||||||
virtual const Moses::FFState* EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const;
|
virtual Moses::FFState* BlankState(const Manager &mgr, const PhraseImpl &input) const;
|
||||||
|
virtual Moses::FFState* EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const;
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
EvaluateInIsolation(const System &system,
|
EvaluateInIsolation(const System &system,
|
||||||
|
@ -24,8 +24,11 @@ public:
|
|||||||
size_t GetStatefulInd() const
|
size_t GetStatefulInd() const
|
||||||
{ return m_statefulInd; }
|
{ return m_statefulInd; }
|
||||||
|
|
||||||
|
//! return uninitialise state
|
||||||
|
virtual Moses::FFState* BlankState(const Manager &mgr, const PhraseImpl &input) const = 0;
|
||||||
|
|
||||||
//! return the state associated with the empty hypothesis for a given sentence
|
//! return the state associated with the empty hypothesis for a given sentence
|
||||||
virtual const Moses::FFState* EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const = 0;
|
virtual Moses::FFState* EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const = 0;
|
||||||
|
|
||||||
virtual Moses::FFState* EvaluateWhenApplied(const Manager &mgr,
|
virtual Moses::FFState* EvaluateWhenApplied(const Manager &mgr,
|
||||||
const Hypothesis &hypo,
|
const Hypothesis &hypo,
|
||||||
|
@ -99,8 +99,13 @@ void KENLM::SetParameter(const std::string& key, const std::string& value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Moses::FFState* KENLM::BlankState(const Manager &mgr, const PhraseImpl &input) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//! return the state associated with the empty hypothesis for a given sentence
|
//! return the state associated with the empty hypothesis for a given sentence
|
||||||
const Moses::FFState* KENLM::EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const
|
Moses::FFState* KENLM::EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const
|
||||||
{
|
{
|
||||||
MemPool &pool = mgr.GetPool();
|
MemPool &pool = mgr.GetPool();
|
||||||
KenLMState *ret = new (pool.Allocate<KenLMState>()) KenLMState();
|
KenLMState *ret = new (pool.Allocate<KenLMState>()) KenLMState();
|
||||||
|
@ -23,8 +23,10 @@ public:
|
|||||||
|
|
||||||
virtual void Load(System &system);
|
virtual void Load(System &system);
|
||||||
|
|
||||||
|
virtual Moses::FFState* BlankState(const Manager &mgr, const PhraseImpl &input) const;
|
||||||
|
|
||||||
//! return the state associated with the empty hypothesis for a given sentence
|
//! return the state associated with the empty hypothesis for a given sentence
|
||||||
virtual const Moses::FFState* EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const;
|
virtual Moses::FFState* EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const;
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
EvaluateInIsolation(const System &system,
|
EvaluateInIsolation(const System &system,
|
||||||
|
@ -117,7 +117,12 @@ void LanguageModel::SetParameter(const std::string& key, const std::string& valu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Moses::FFState* LanguageModel::EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const
|
Moses::FFState* LanguageModel::BlankState(const Manager &mgr, const PhraseImpl &input) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Moses::FFState* LanguageModel::EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const
|
||||||
{
|
{
|
||||||
MemPool &pool = mgr.GetPool();
|
MemPool &pool = mgr.GetPool();
|
||||||
return new (pool.Allocate<LMState>()) LMState(pool, m_bos);
|
return new (pool.Allocate<LMState>()) LMState(pool, m_bos);
|
||||||
|
@ -50,7 +50,8 @@ public:
|
|||||||
|
|
||||||
virtual void SetParameter(const std::string& key, const std::string& value);
|
virtual void SetParameter(const std::string& key, const std::string& value);
|
||||||
|
|
||||||
virtual const Moses::FFState* EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const;
|
virtual Moses::FFState* BlankState(const Manager &mgr, const PhraseImpl &input) const;
|
||||||
|
virtual Moses::FFState* EmptyHypothesisState(const Manager &mgr, const PhraseImpl &input) const;
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
EvaluateInIsolation(const System &system,
|
EvaluateInIsolation(const System &system,
|
||||||
|
@ -21,10 +21,18 @@ Hypothesis::Hypothesis(Manager &mgr)
|
|||||||
{
|
{
|
||||||
MemPool &pool = m_mgr.GetPool();
|
MemPool &pool = m_mgr.GetPool();
|
||||||
|
|
||||||
size_t numStatefulFFs = m_mgr.GetSystem().featureFunctions.GetStatefulFeatureFunctions().size();
|
|
||||||
m_ffStates = (const Moses::FFState **) pool.Allocate(sizeof(Moses::FFState*) * numStatefulFFs);
|
|
||||||
|
|
||||||
m_scores = new (pool.Allocate<Scores>()) Scores(pool, m_mgr.GetSystem().featureFunctions.GetNumScores());
|
m_scores = new (pool.Allocate<Scores>()) Scores(pool, m_mgr.GetSystem().featureFunctions.GetNumScores());
|
||||||
|
|
||||||
|
// FF states
|
||||||
|
const std::vector<const StatefulFeatureFunction*> &sfffs = m_mgr.GetSystem().featureFunctions.GetStatefulFeatureFunctions();
|
||||||
|
size_t numStatefulFFs = sfffs.size();
|
||||||
|
m_ffStates = (Moses::FFState **) pool.Allocate(sizeof(Moses::FFState*) * numStatefulFFs);
|
||||||
|
|
||||||
|
BOOST_FOREACH(const StatefulFeatureFunction *sfff, sfffs) {
|
||||||
|
size_t statefulInd = sfff->GetStatefulInd();
|
||||||
|
Moses::FFState *state = sfff->BlankState(mgr, mgr.GetInput());
|
||||||
|
m_ffStates[statefulInd] = state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Hypothesis::~Hypothesis() {
|
Hypothesis::~Hypothesis() {
|
||||||
@ -127,7 +135,7 @@ void Hypothesis::EmptyHypothesisState(const PhraseImpl &input)
|
|||||||
const std::vector<const StatefulFeatureFunction*> &sfffs = m_mgr.GetSystem().featureFunctions.GetStatefulFeatureFunctions();
|
const std::vector<const StatefulFeatureFunction*> &sfffs = m_mgr.GetSystem().featureFunctions.GetStatefulFeatureFunctions();
|
||||||
BOOST_FOREACH(const StatefulFeatureFunction *sfff, sfffs) {
|
BOOST_FOREACH(const StatefulFeatureFunction *sfff, sfffs) {
|
||||||
size_t statefulInd = sfff->GetStatefulInd();
|
size_t statefulInd = sfff->GetStatefulInd();
|
||||||
const Moses::FFState *state = sfff->EmptyHypothesisState(m_mgr, input);
|
Moses::FFState *state = sfff->EmptyHypothesisState(m_mgr, input);
|
||||||
m_ffStates[statefulInd] = state;
|
m_ffStates[statefulInd] = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,7 +147,7 @@ void Hypothesis::EvaluateWhenApplied()
|
|||||||
size_t statefulInd = sfff->GetStatefulInd();
|
size_t statefulInd = sfff->GetStatefulInd();
|
||||||
const Moses::FFState *prevState = m_prevHypo->GetState(statefulInd);
|
const Moses::FFState *prevState = m_prevHypo->GetState(statefulInd);
|
||||||
assert(prevState);
|
assert(prevState);
|
||||||
const Moses::FFState *state = sfff->EvaluateWhenApplied(m_mgr, *this, *prevState, *m_scores);
|
Moses::FFState *state = sfff->EvaluateWhenApplied(m_mgr, *this, *prevState, *m_scores);
|
||||||
m_ffStates[statefulInd] = state;
|
m_ffStates[statefulInd] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ protected:
|
|||||||
const Moses::Range *m_range;
|
const Moses::Range *m_range;
|
||||||
const Hypothesis *m_prevHypo;
|
const Hypothesis *m_prevHypo;
|
||||||
|
|
||||||
const Moses::FFState **m_ffStates;
|
Moses::FFState **m_ffStates;
|
||||||
Scores *m_scores;
|
Scores *m_scores;
|
||||||
Moses::Range m_currTargetWordsRange;
|
Moses::Range m_currTargetWordsRange;
|
||||||
};
|
};
|
||||||
|
@ -35,6 +35,9 @@ public:
|
|||||||
Moses::Bitmaps &GetBitmaps()
|
Moses::Bitmaps &GetBitmaps()
|
||||||
{ return *m_bitmaps; }
|
{ return *m_bitmaps; }
|
||||||
|
|
||||||
|
const PhraseImpl &GetInput() const
|
||||||
|
{ return *m_input; }
|
||||||
|
|
||||||
const InputPaths &GetInputPaths() const
|
const InputPaths &GetInputPaths() const
|
||||||
{ return m_inputPaths; }
|
{ return m_inputPaths; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user