recreate lex ro framework from Moses

This commit is contained in:
Hieu Hoang 2016-03-22 23:56:52 +00:00
parent 269cc649ea
commit 949fcddbd0
6 changed files with 113 additions and 1 deletions

View File

@ -36,4 +36,14 @@ bool BidirectionalReorderingState::operator==(const FFState& o) const
return ret;
}
void BidirectionalReorderingState::Expand(const System &system,
const LexicalReordering &ff,
const Hypothesis &hypo,
size_t phraseTableInd,
Scores &scores,
FFState &state) const
{
}
} /* namespace Moses2 */

View File

@ -18,6 +18,16 @@ public:
size_t hash() const;
virtual bool operator==(const FFState& other) const;
virtual std::string ToString() const
{ return ""; }
void Expand(const System &system,
const LexicalReordering &ff,
const Hypothesis &hypo,
size_t phraseTableInd,
Scores &scores,
FFState &state) const;
protected:
const LRState *m_backward;
const LRState *m_forward;

View File

@ -0,0 +1,46 @@
/*
* HReorderingBackwardState.cpp
*
* Created on: 22 Mar 2016
* Author: hieu
*/
#include "HReorderingBackwardState.h"
namespace Moses2 {
HReorderingBackwardState::HReorderingBackwardState() {
// TODO Auto-generated constructor stub
}
HReorderingBackwardState::~HReorderingBackwardState() {
// TODO Auto-generated destructor stub
}
size_t HReorderingBackwardState::hash() const
{
}
bool HReorderingBackwardState::operator==(const FFState& other) const
{
}
std::string HReorderingBackwardState::ToString() const
{
}
void HReorderingBackwardState::Expand(const System &system,
const LexicalReordering &ff,
const Hypothesis &hypo,
size_t phraseTableInd,
Scores &scores,
FFState &state) const
{
}
} /* namespace Moses2 */

View File

@ -0,0 +1,31 @@
/*
* HReorderingBackwardState.h
*
* Created on: 22 Mar 2016
* Author: hieu
*/
#pragma once
#include "LRState.h"
namespace Moses2 {
class HReorderingBackwardState : public LRState
{
public:
HReorderingBackwardState();
virtual ~HReorderingBackwardState();
size_t hash() const;
virtual bool operator==(const FFState& other) const;
virtual std::string ToString() const;
void Expand(const System &system,
const LexicalReordering &ff,
const Hypothesis &hypo,
size_t phraseTableInd,
Scores &scores,
FFState &state) const;
};
} /* namespace Moses2 */

View File

@ -8,6 +8,7 @@
#include <boost/foreach.hpp>
#include "LexicalReordering.h"
#include "PhraseBasedReorderingState.h"
#include "BidirectionalReorderingState.h"
#include "../../TranslationModel/PhraseTable.h"
#include "../../System.h"
#include "../../PhraseImpl.h"
@ -113,7 +114,14 @@ void LexicalReordering::SetParameter(const std::string& key, const std::string&
FFState* LexicalReordering::BlankState(MemPool &pool) const
{
return new (pool.Allocate<PhraseBasedReorderingState>()) PhraseBasedReorderingState();
FFState *ret;
if (m_phraseBased) {
ret = new (pool.Allocate<PhraseBasedReorderingState>()) PhraseBasedReorderingState();
}
else {
ret = new (pool.Allocate<BidirectionalReorderingState>()) BidirectionalReorderingState();
}
return ret;
}
void LexicalReordering::EmptyHypothesisState(FFState &state,
@ -121,9 +129,15 @@ void LexicalReordering::EmptyHypothesisState(FFState &state,
const InputType &input,
const Hypothesis &hypo) const
{
if (m_phraseBased) {
PhraseBasedReorderingState &stateCast = static_cast<PhraseBasedReorderingState&>(state);
stateCast.path = &hypo.GetInputPath();
stateCast.targetPhrase = &hypo.GetTargetPhrase();
}
else {
BidirectionalReorderingState &stateCast = static_cast<BidirectionalReorderingState&>(state);
}
}
void LexicalReordering::EvaluateInIsolation(MemPool &pool,

View File

@ -34,6 +34,7 @@ alias deps : ../../..//z ../../..//boost_iostreams ../../..//boost_filesystem .
FF/LexicalReordering/LexicalReordering.cpp
FF/LexicalReordering/PhraseBasedReorderingState.cpp
FF/LexicalReordering/BidirectionalReorderingState.cpp
FF/LexicalReordering/HReorderingBackwardState.cpp
# LM/LanguageModelDALM.cpp
LM/LanguageModel.cpp