00001 #pragma once
00002
00003 # include "moses/FF/FFState.h"
00004 # include "moses/Manager.h"
00005 # include <set>
00006 # include <map>
00007 # include <string>
00008 # include <vector>
00009
00010 #include "KenOSM.h"
00011
00012 namespace Moses
00013 {
00014
00015 class osmState : public FFState
00016 {
00017 public:
00018 osmState(const lm::ngram::State & val);
00019 virtual size_t hash() const;
00020 virtual bool operator==(const FFState& other) const;
00021
00022 void saveState(int jVal, int eVal, std::map <int , std::string> & gapVal);
00023 int getJ()const {
00024 return j;
00025 }
00026 int getE()const {
00027 return E;
00028 }
00029 std::map <int , std::string> getGap() const {
00030 return gap;
00031 }
00032
00033 lm::ngram::State getLMState() const {
00034 return lmState;
00035 }
00036
00037 void print() const;
00038 std::string getName() const;
00039
00040 protected:
00041 int j, E;
00042 std::map <int,std::string> gap;
00043 lm::ngram::State lmState;
00044 };
00045
00046 class osmHypothesis
00047 {
00048
00049 private:
00050
00051
00052 std::vector <std::string> operations;
00053 std::map <int,std::string> gap;
00054 int j;
00055 int E;
00056 lm::ngram::State lmState;
00057
00058 int gapCount;
00059 int deletionCount;
00060 int openGapCount;
00061 int gapWidth;
00062 double opProb;
00063
00064 std::vector <std::string> currE;
00065 std::vector <std::string> currF;
00066 std::vector < std::pair < std::set <int> , std::set <int> > > ceptsInPhrase;
00067 std::set <int> targetNullWords;
00068 std::set <int> sourceNullWords;
00069
00070 int closestGap(std::map <int,std::string> gap,int j1, int & gp);
00071 int firstOpenGap(std::vector <int> & coverageVector);
00072 std::string intToString(int);
00073 int getOpenGaps();
00074 int isTranslationOperation(int j);
00075 void removeReorderingOperations();
00076
00077 void getMeCepts ( std::set <int> & eSide , std::set <int> & fSide , std::map <int , std::vector <int> > & tS , std::map <int , std::vector <int> > & sT);
00078
00079 public:
00080
00081 osmHypothesis();
00082 ~osmHypothesis() {};
00083 void generateOperations(int & startIndex, int j1 , int contFlag , Bitmap & coverageVector , std::string english , std::string german , std::set <int> & targetNullWords , std::vector <std::string> & currF);
00084 void generateDeleteOperations(std::string english, int currTargetIndex, std::set <int> doneTargetIndexes);
00085 void calculateOSMProb(OSMLM& ptrOp);
00086 void computeOSMFeature(int startIndex , Bitmap & coverageVector);
00087 void constructCepts(std::vector <int> & align , int startIndex , int endIndex, int targetPhraseLength);
00088 void setPhrases(std::vector <std::string> & val1 , std::vector <std::string> & val2) {
00089 currF = val1;
00090 currE = val2;
00091 }
00092 void setState(const FFState* prev_state);
00093 osmState * saveState();
00094 void print();
00095 void populateScores(std::vector <float> & scores , const int numFeatures);
00096 void setState(const lm::ngram::State & val) {
00097 lmState = val;
00098 }
00099
00100 };
00101
00102 }
00103
00104
00105