/* EGYPT Toolkit for Statistical Machine Translation Written by Yaser Al-Onaizan, Jan Curin, Michael Jahr, Kevin Knight, John Lafferty, Dan Melamed, David Purdy, Franz Och, Noah Smith, and David Yarowsky. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _model3_h #define _model3_h 1 #include #include #include #include #include #include #include "Vector.h" #include #if __GNUC__>2 #include using __gnu_cxx::hash_map; #else #include #endif #include #include #include #include "MoveSwapMatrix.h" #include "TTables.h" #include "ATables.h" #include "NTables.h" #include "getSentence.h" #include "defs.h" #include "model2.h" #include "Perplexity.h" #include "transpair_model3.h" #include "transpair_modelhmm.h" #include "alignment.h" #include "vocab.h" #include "D4Tables.h" #include "AlignTables.h" class model3 : public model2 { public: amodel dTable; amodel dCountTable; PROB p0,p1; double p0_count, p1_count ; nmodel nTable; nmodel nCountTable; hmm*h; public: void setHMM(hmm*_h){h=_h;} model3(model2& m2); ~model3(); // methods void transfer(sentenceHandler&, bool, Perplexity&, Perplexity&,bool updateT=1); void transferSimple(sentenceHandler&, bool, Perplexity&, Perplexity&,bool updateT=1); void load_tables(const char *nfile, const char *dfile, const char *p0file); void em(int, sentenceHandler&); int viterbi(int, int, int,int); private: LogProb prob_of_special(Vector&, Vector&, tmodel&, Vector&, Vector&); LogProb prob_of_target_and_alignment_given_source(Vector&, Vector&, tmodel&, Vector&, Vector&); LogProb prob_of_target_given_source(tmodel&, Vector&, Vector&); LogProb scoreOfMove(Vector&, Vector&, Vector&, Vector&, tmodel&, WordIndex, WordIndex); LogProb scoreOfSwap(Vector&, Vector&, Vector&, tmodel&, int, int); void hillClimb(Vector&, Vector&, Vector&, Vector&, LogProb&, tmodel&, int, int); void findBestAlignment(Vector&, Vector&, Vector&, Vector&, LogProb&,int , int); void findAlignmentsNeighborhood( Vector&, Vector&, LogProb&align_total_count, alignmodel&neighborhood, int, int); void collectCountsOverAlignement(const Vector& es, const Vector& fs, const Vector&, LogProb , float count); LogProb viterbi_model2(const transpair_model3&ef, alignment&output, int pair_no,int i_peg = -1 , int j_peg = -1 )const; LogProb _viterbi_model2(const transpair_model2&ef, alignment&output, int i_peg = -1 , int j_peg = -1 )const; LogProb viterbi_model2(const transpair_modelhmm&ef, alignment&output, int pair_no,int i_peg = -1 , int j_peg = -1 )const; private: void estimate_t_a_d(sentenceHandler& sHandler1, Perplexity& perp, Perplexity& perp,bool simple, bool dump_files,bool updateT); void viterbi_loop(Perplexity&, Perplexity&, sentenceHandler&, bool, const char*,bool,string model); template void viterbi_loop_with_tricks(Perplexity&, Perplexity&, sentenceHandler&, bool, const char*, bool, string model, bool final,A*d4m,B*d5m); }; #endif