/* 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. */ /*-- alignment: 'checked' alignment representation with autom. calc. of fertilities Franz Josef Och (30/07/99) --*/ #ifndef alignment_h_fjo_defined #define alignment_h_fjo_defined #include "Vector.h" #include #include "defs.h" #include "myassert.h" class al_struct { public: al_struct() : prev(0),next(0) {} PositionIndex prev,next; }; class alignment { private: Vector a; Vector positionSum,f; public: Vector als_i; Vector als_j; PositionIndex l,m; alignment() {} alignment(PositionIndex _l, PositionIndex _m) : a(_m+1, (PositionIndex)0), positionSum(_l+1, (PositionIndex)0), f(_l+1, (PositionIndex)0), als_i(_l+1,0),als_j(_m+1),l(_l), m(_m) { f[0]=m; for(PositionIndex j=1; j<=m; j++) { if( j>1 ) als_j[j].prev= j-1; if( j0); massert(j>0); positionSum[old_aj]-=j; // ausfuegen PositionIndex prev=als_j[j].prev; PositionIndex next=als_j[j].next; if( next ) als_j[next].prev=prev; if( prev ) als_j[prev].next=next; else als_i[old_aj]=next; // neue Position suchen PositionIndex lfd=als_i[aj],llfd=0; while( lfd && lfd& getAlignment() const { return a ; } PositionIndex get_al(PositionIndex j)const { massert(jm ) return 0; for(unsigned int i=1; i<=l; i++) if( f[i]>=MAX_FERTILITY ) return 0; return 1; } friend class transpair_model5; }; #endif