mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-08-16 23:10:31 +03:00
refactor state info to work with moses2
This commit is contained in:
parent
aeecda9a8e
commit
6d276661e0
@ -13,34 +13,6 @@ using namespace std;
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
class OSMState: public FFState
|
||||
{
|
||||
public:
|
||||
int targetLen;
|
||||
|
||||
OSMState()
|
||||
{
|
||||
// uninitialised
|
||||
}
|
||||
|
||||
virtual size_t hash() const
|
||||
{
|
||||
return (size_t) targetLen;
|
||||
}
|
||||
virtual bool operator==(const FFState& o) const
|
||||
{
|
||||
const OSMState& other = static_cast<const OSMState&>(o);
|
||||
return targetLen == other.targetLen;
|
||||
}
|
||||
|
||||
virtual std::string ToString() const
|
||||
{
|
||||
stringstream sb;
|
||||
sb << targetLen;
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -67,15 +39,17 @@ void OpSequenceModel::Load(System &system)
|
||||
|
||||
FFState* OpSequenceModel::BlankState(MemPool &pool, const System &sys) const
|
||||
{
|
||||
return new (pool.Allocate<OSMState>()) OSMState();
|
||||
return new (pool.Allocate<osmState>()) osmState();
|
||||
}
|
||||
|
||||
void OpSequenceModel::EmptyHypothesisState(FFState &state,
|
||||
const ManagerBase &mgr, const InputType &input,
|
||||
const Hypothesis &hypo) const
|
||||
{
|
||||
OSMState &stateCast = static_cast<OSMState&>(state);
|
||||
stateCast.targetLen = 0;
|
||||
lm::ngram::State startState = OSM->BeginSentenceState();
|
||||
|
||||
osmState &stateCast = static_cast<osmState&>(state);
|
||||
stateCast.setState(startState);
|
||||
}
|
||||
|
||||
void OpSequenceModel::EvaluateInIsolation(MemPool &pool,
|
||||
@ -217,7 +191,8 @@ void OpSequenceModel::EvaluateWhenApplied(const ManagerBase &mgr,
|
||||
|
||||
scores.PlusEquals(mgr.system, *this, scoresVec);
|
||||
|
||||
//return obj.saveState();
|
||||
osmState &stateCast = static_cast<osmState&>(state);
|
||||
obj.saveState(stateCast);
|
||||
}
|
||||
|
||||
void OpSequenceModel::EvaluateWhenApplied(const SCFG::Manager &mgr,
|
||||
|
@ -6,12 +6,11 @@ using namespace lm::ngram;
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
osmState::osmState(const State & val)
|
||||
:j(0)
|
||||
,E(0)
|
||||
void osmState::setState(const lm::ngram::State & val)
|
||||
{
|
||||
j = 0;
|
||||
E = 0;
|
||||
lmState = val;
|
||||
|
||||
}
|
||||
|
||||
void osmState::saveState(int jVal, int eVal, map <int , string> & gapVal)
|
||||
@ -81,12 +80,10 @@ void osmHypothesis :: setState(const FFState* prev_state)
|
||||
}
|
||||
}
|
||||
|
||||
osmState * osmHypothesis :: saveState()
|
||||
void osmHypothesis :: saveState(osmState &state)
|
||||
{
|
||||
|
||||
osmState * statePtr = new osmState(lmState);
|
||||
statePtr->saveState(j,E,gap);
|
||||
return statePtr;
|
||||
state.setState(lmState);
|
||||
state.saveState(j,E,gap);
|
||||
}
|
||||
|
||||
int osmHypothesis :: isTranslationOperation(int x)
|
||||
|
@ -14,7 +14,11 @@ namespace Moses2
|
||||
class osmState : public FFState
|
||||
{
|
||||
public:
|
||||
osmState(const lm::ngram::State & val);
|
||||
osmState()
|
||||
{}
|
||||
|
||||
void setState(const lm::ngram::State & val);
|
||||
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
@ -92,7 +96,7 @@ public:
|
||||
currE = val2;
|
||||
}
|
||||
void setState(const FFState* prev_state);
|
||||
osmState * saveState();
|
||||
void saveState(osmState &state);
|
||||
void print();
|
||||
void populateScores(std::vector <float> & scores , const int numFeatures);
|
||||
void setState(const lm::ngram::State & val) {
|
||||
|
Loading…
Reference in New Issue
Block a user