/* Copyright (C) 2000,2001 Franz Josef Och (RWTH Aachen - Lehrstuhl fuer Informatik VI) This file is part of GIZA++ ( extension of GIZA ). 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 WordClasses_h_DEFINED #define WordClasses_h_DEFINED #include #include #include class WordClasses { private: map Sw2c; map Sc2int; Vector Sint2c; Vector w2c; unsigned int classes; public: WordClasses() : classes(1) { Sint2c.push_back("0"); Sc2int["0"]=0; } template bool read(istream&in,const MAPPER&m) { string sline; int maxword=0; while(getline(in,sline)) { string word,wclass; istrstream iline(sline.c_str()); iline>>word>>wclass; maxword=max(m(word),maxword); assert(Sw2c.count(word)==0); Sw2c[word]=wclass; if( !Sc2int.count(wclass) ) { Sc2int[wclass]=classes++; Sint2c.push_back(wclass); assert(classes==Sint2c.size()); } } w2c=Vector(maxword+1,0); for(map::const_iterator i=Sw2c.begin();i!=Sw2c.end();++i) w2c[m(i->first)]=Sc2int[i->second]; cout << "Read classes: #words: " << maxword << " " << " #classes: "<< classes <=0&&int(w)second; else { cerr << "WARNING: class " << x << " not found.\n"; return 0; } } string classString(unsigned int cnr)const { if( cnr