00001 #pragma once
00002
00003
00004 # include "moses/FF/FFState.h"
00005 # include "moses/Manager.h"
00006 # include <set>
00007 # include <map>
00008 # include <string>
00009 # include <vector>
00010 # include "moses/FF/Dsg-Feature/Desegmenter.h"
00011 # include "KenDsg.h"
00012
00013
00014 namespace Moses
00015 {
00016
00017 class dsgState : public FFState
00018 {
00019 public:
00020
00021 dsgState(const lm::ngram::State & val);
00022 virtual bool operator==(const FFState& other) const;
00023 void saveState( std::vector<std::string> bufferVal,std::vector<int> spanVal, float deltaValue);
00024
00025 std::vector<std::string> getBuffer() const {
00026 return buffer;
00027 }
00028
00029 std::vector<int> getSpan() const {
00030 return span;
00031 }
00032
00033 lm::ngram::State getLMState() const {
00034 return lmState;
00035 }
00036
00037 float getDelta() const {
00038 return delta;
00039 }
00040
00041 void setDelta(double val1 ) {
00042 delta = val1;
00043 }
00044
00045 void print() const;
00046 std::string getName() const;
00047
00048 virtual size_t hash() const;
00049
00050
00051 protected:
00052 std::vector<std::string> buffer;
00053 std::vector<int> span;
00054 lm::ngram::State lmState;
00055 double delta;
00056 };
00057
00058
00059
00060 class dsgHypothesis
00061 {
00062
00063 private:
00064 std::vector<std::string> m_buffer;
00065 std::vector<int> m_span;
00066 lm::ngram::State lmState;
00067 std::vector<std::string> m_curr_phr;
00068 double delta;
00069
00070 double lmProb;
00071 int discontig0;
00072 int discontig1;
00073 int discontig2;
00074 double UnsegWP;
00075
00076 public:
00077
00078 dsgHypothesis();
00079 ~dsgHypothesis() {};
00080 void calculateDsgProb(DsgLM& ptrDsgLM, Desegmenter &, bool isCompleted, const AlignmentInfo &align, int sourceOffset, bool optimistic);
00081 void calculateDsgProbinIsol(DsgLM& ptrDsgLM, Desegmenter &, const AlignmentInfo &align);
00082
00083 void setPhrases(std::vector<std::string> & val1 ) {
00084 m_curr_phr = val1;
00085 }
00086
00087 void setDelta(double val1 ) {
00088 delta = val1;
00089 }
00090
00091 void setState(const FFState* prev_state);
00092 dsgState * saveState();
00093 void print();
00094 void populateScores(std::vector <float> & scores , const int numFeatures);
00095 void setState(const lm::ngram::State & val) {
00096 lmState = val;
00097 }
00098
00099 bool isPrefix(const std::string &);
00100 bool isSuffix(const std::string &);
00101 bool isStem(const std::string &);
00102 bool isValidChain(const std::string &, std::vector<std::string> &chain);
00103 vector<string> grouper(std::vector<std::string> &,std::vector<std::vector<int> > &,int,const AlignmentInfo &align,bool);
00104
00105 };
00106 }
00107
00108