#pragma once # include # include # include # include #include "KenOSM.h" # include "../FFState.h" # include "../../legacy/Bitmap.h" namespace Moses2 { class osmState : public FFState { public: osmState() {} void setState(const lm::ngram::State & val); virtual size_t hash() const; virtual bool operator==(const FFState& other) const; virtual std::string ToString() const { return "osmState"; } void saveState(int jVal, int eVal, std::map & gapVal); int getJ()const { return j; } int getE()const { return E; } std::map getGap() const { return gap; } lm::ngram::State getLMState() const { return lmState; } void print() const; std::string getName() const; protected: int j, E; std::map gap; lm::ngram::State lmState; }; class osmHypothesis { private: std::vector operations; // List of operations required to generated this hyp ... std::map gap; // Maintains gap history ... int j; // Position after the last source word generated ... int E; // Position after the right most source word so far generated ... lm::ngram::State lmState; // KenLM's Model State ... int gapCount; // Number of gaps inserted ... int deletionCount; int openGapCount; int gapWidth; double opProb; std::vector currE; std::vector currF; std::vector < std::pair < std::set , std::set > > ceptsInPhrase; std::set targetNullWords; std::set sourceNullWords; int closestGap(std::map gap,int j1, int & gp); int firstOpenGap(std::vector & coverageVector); std::string intToString(int); int getOpenGaps(); int isTranslationOperation(int j); void removeReorderingOperations(); void getMeCepts ( std::set & eSide , std::set & fSide , std::map > & tS , std::map > & sT); public: osmHypothesis(); ~osmHypothesis() {}; void generateOperations(int & startIndex, int j1 , int contFlag , Bitmap & coverageVector , std::string english , std::string german , std::set & targetNullWords , std::vector & currF); void generateDeleteOperations(std::string english, int currTargetIndex, std::set doneTargetIndexes); void calculateOSMProb(OSMLM& ptrOp); void computeOSMFeature(int startIndex , Bitmap & coverageVector); void constructCepts(std::vector & align , int startIndex , int endIndex, int targetPhraseLength); void setPhrases(std::vector & val1 , std::vector & val2) { currF = val1; currE = val2; } void setState(const FFState* prev_state); void saveState(osmState &state); void print(); void populateScores(std::vector & scores , const int numFeatures); void setState(const lm::ngram::State & val) { lmState = val; } }; } // namespace