mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
separate BidirectionalReorderingState into its own file
This commit is contained in:
parent
ba9a9b3ef9
commit
105faa5673
@ -2545,6 +2545,16 @@
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/moses/parameters/SyntaxOptions.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>FF/LexicalReordering/BidirectionalReorderingState.cpp</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/moses/FF/LexicalReordering/BidirectionalReorderingState.cpp</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>FF/LexicalReordering/BidirectionalReorderingState.h</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/moses/FF/LexicalReordering/BidirectionalReorderingState.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>FF/LexicalReordering/HReorderingBackwardState.cpp</name>
|
||||
<type>1</type>
|
||||
|
38
moses/FF/LexicalReordering/BidirectionalReorderingState.cpp
Normal file
38
moses/FF/LexicalReordering/BidirectionalReorderingState.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "BidirectionalReorderingState.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
///////////////////////////
|
||||
//BidirectionalReorderingState
|
||||
|
||||
size_t BidirectionalReorderingState::hash() const
|
||||
{
|
||||
size_t ret = m_backward->hash();
|
||||
boost::hash_combine(ret, m_forward->hash());
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool BidirectionalReorderingState::operator==(const FFState& o) const
|
||||
{
|
||||
if (&o == this) return 0;
|
||||
|
||||
BidirectionalReorderingState const &other
|
||||
= static_cast<BidirectionalReorderingState const&>(o);
|
||||
|
||||
bool ret = (*m_backward == *other.m_backward) && (*m_forward == *other.m_forward);
|
||||
return ret;
|
||||
}
|
||||
|
||||
LRState*
|
||||
BidirectionalReorderingState::
|
||||
Expand(const TranslationOption& topt, const InputType& input,
|
||||
ScoreComponentCollection* scores) const
|
||||
{
|
||||
LRState *newbwd = m_backward->Expand(topt,input, scores);
|
||||
LRState *newfwd = m_forward->Expand(topt, input, scores);
|
||||
return new BidirectionalReorderingState(m_configuration, newbwd, newfwd, m_offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
38
moses/FF/LexicalReordering/BidirectionalReorderingState.h
Normal file
38
moses/FF/LexicalReordering/BidirectionalReorderingState.h
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#include "LexicalReorderingState.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
class BidirectionalReorderingState
|
||||
: public LRState
|
||||
{
|
||||
private:
|
||||
const LRState *m_backward;
|
||||
const LRState *m_forward;
|
||||
public:
|
||||
BidirectionalReorderingState(const LRModel &config,
|
||||
const LRState *bw,
|
||||
const LRState *fw, size_t offset)
|
||||
: LRState(config,
|
||||
LRModel::Bidirectional,
|
||||
offset)
|
||||
, m_backward(bw)
|
||||
, m_forward(fw)
|
||||
{ }
|
||||
|
||||
~BidirectionalReorderingState() {
|
||||
delete m_backward;
|
||||
delete m_forward;
|
||||
}
|
||||
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
LRState*
|
||||
Expand(const TranslationOption& topt, const InputType& input,
|
||||
ScoreComponentCollection* scores) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "HReorderingForwardState.h"
|
||||
#include "HReorderingBackwardState.h"
|
||||
#include "PhraseBasedReorderingState.h"
|
||||
#include "BidirectionalReorderingState.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
@ -293,37 +294,5 @@ ComparePrevScores(const TranslationOption *other) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
//BidirectionalReorderingState
|
||||
|
||||
size_t BidirectionalReorderingState::hash() const
|
||||
{
|
||||
size_t ret = m_backward->hash();
|
||||
boost::hash_combine(ret, m_forward->hash());
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool BidirectionalReorderingState::operator==(const FFState& o) const
|
||||
{
|
||||
if (&o == this) return 0;
|
||||
|
||||
BidirectionalReorderingState const &other
|
||||
= static_cast<BidirectionalReorderingState const&>(o);
|
||||
|
||||
bool ret = (*m_backward == *other.m_backward) && (*m_forward == *other.m_forward);
|
||||
return ret;
|
||||
}
|
||||
|
||||
LRState*
|
||||
BidirectionalReorderingState::
|
||||
Expand(const TranslationOption& topt, const InputType& input,
|
||||
ScoreComponentCollection* scores) const
|
||||
{
|
||||
LRState *newbwd = m_backward->Expand(topt,input, scores);
|
||||
LRState *newfwd = m_forward->Expand(topt, input, scores);
|
||||
return new BidirectionalReorderingState(m_configuration, newbwd, newfwd, m_offset);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -195,36 +195,6 @@ protected:
|
||||
ComparePrevScores(const TranslationOption *other) const;
|
||||
};
|
||||
|
||||
//! @todo what is this?
|
||||
class BidirectionalReorderingState
|
||||
: public LRState
|
||||
{
|
||||
private:
|
||||
const LRState *m_backward;
|
||||
const LRState *m_forward;
|
||||
public:
|
||||
BidirectionalReorderingState(const LRModel &config,
|
||||
const LRState *bw,
|
||||
const LRState *fw, size_t offset)
|
||||
: LRState(config,
|
||||
LRModel::Bidirectional,
|
||||
offset)
|
||||
, m_backward(bw)
|
||||
, m_forward(fw)
|
||||
{ }
|
||||
|
||||
~BidirectionalReorderingState() {
|
||||
delete m_backward;
|
||||
delete m_forward;
|
||||
}
|
||||
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
LRState*
|
||||
Expand(const TranslationOption& topt, const InputType& input,
|
||||
ScoreComponentCollection* scores) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user