// // C++ Implementation: string_int // // Description: // // // Author: Børre Gaup , (C) 2008 // // Copyright: See COPYING file that comes with this distribution // // #include "string_int.h" #include int string_int::id = 1; string_int::string_int() { str_int = map(); compoundpermitflag = "65530"; compoundbegin = "65531"; compoundmiddle = "65532"; compoundend = "65533"; compoundforbidflag = "65534"; onlyincompound = "65535"; } int string_int::add_int_vec(string str) { int tmp = str_int[str]; if(tmp == 0){ str_int[str] = string_int::id; string_int::id++; return string_int::id - 1; } else return tmp; } string string_int::get_string(int i) { map::iterator it = str_int.begin(); while(it != str_int.end()){ if(it->second == i) return it->first; it++; } return NULL; } void string_int::print_ders(fstream * aff_file, map > ders) { for(map::iterator it = str_int.begin(); it != str_int.end(); it++) { (*aff_file) << it->second << " "; (*aff_file) << it->first << "/"; set affixes = ders[it->first]; if(affixes.size() > 0) { set::iterator jj = affixes.begin(); (*aff_file) << (*jj); ++jj; for( ; jj != affixes.end(); ++jj) { (*aff_file) << "," << (*jj); } } (*aff_file) << endl; } } void string_int::print_affixes(fstream * aff_file) { map compoundHash; compoundHash["GaBO"] = "/" + compoundpermitflag + "," + compoundbegin + "," + compoundmiddle + "," + onlyincompound; compoundHash["GaIAL"] = "/" + compoundpermitflag + "," + compoundend; compoundHash["GaIBOE"] = "/" + compoundpermitflag; compoundHash["GaIE"] = "/" + compoundpermitflag + "," + compoundend; compoundHash["GpBO"] = "/" + compoundpermitflag + "," + compoundbegin + "," + compoundmiddle + "," + onlyincompound; compoundHash["GpIAL"] = "/" + compoundpermitflag + "," + compoundend; compoundHash["GpIBOE"] = "/" + compoundpermitflag; compoundHash["GpIE"] = "/" + compoundpermitflag + "," + compoundend; compoundHash["NALX"] = "/" + compoundpermitflag + "," + compoundbegin; compoundHash["NAPI"] = "/" + compoundforbidflag; compoundHash["NAPIB"] = "/" + compoundpermitflag + "," + compoundbegin; compoundHash["NAPO"] = "/" + compoundpermitflag + "," + compoundmiddle + "," + onlyincompound; compoundHash["NBO"] = "/" + compoundpermitflag + "," + compoundbegin + "," + compoundmiddle + "," + onlyincompound; compoundHash["NBOX"] = "/" + compoundpermitflag + "," + compoundbegin + "," + compoundmiddle + "," + onlyincompound; compoundHash["NI"] = "/" + compoundforbidflag; compoundHash["NIALR"] = "/" + compoundpermitflag + "," + compoundbegin + "," + compoundend; compoundHash["NIBE"] = "/" + compoundpermitflag + "," + compoundbegin + "," + compoundend; compoundHash["NIBX"] = "/" + compoundpermitflag + "," + compoundbegin; compoundHash["NIE"] = "/" + compoundpermitflag + "," + compoundend; compoundHash["NIOE"] = "/" + compoundpermitflag + "," + compoundmiddle + "," + compoundend; compoundHash["NPIBOE"] = "/" + compoundpermitflag; compoundHash["NPIE"] = "/" + compoundpermitflag + "," + compoundend; compoundHash["NaIOE"] = "/" + compoundpermitflag + "," + compoundmiddle + "," + compoundend; compoundHash["NeAPB"] = "/" + compoundpermitflag + "," + compoundbegin + "," + onlyincompound; compoundHash["NeAPI"] = "/" + compoundforbidflag; compoundHash["NeAPOE"] = "/" + compoundpermitflag + "," + compoundmiddle + "," + compoundend + "," + onlyincompound; compoundHash["NeI"] = "/" + compoundforbidflag; compoundHash["NeP"] = "/" + compoundforbidflag; compoundHash["NePABO"] = "/" + compoundpermitflag + "," + compoundbegin + "," + compoundmiddle + "," + onlyincompound; compoundHash["NePE"] = "/" + compoundpermitflag + "," + compoundend + "," + onlyincompound; compoundHash["NePI"] = "/" + compoundforbidflag; compoundHash["NePIB"] = "/" + compoundpermitflag + "," + compoundbegin; compoundHash["NpIOE"] = "/" + compoundpermitflag + "," + compoundmiddle + "," + compoundend; compoundHash["UAI"] = "/" + compoundforbidflag; compoundHash["UAIBP"] = "/" + compoundpermitflag + "," + compoundbegin; compoundHash["UAIE"] = "/" + compoundpermitflag + "," + compoundend; compoundHash["UAIEBO"] = "/" + compoundpermitflag; compoundHash["UIOE"] = "/" + compoundpermitflag + "," + compoundmiddle + "," + compoundend; compoundHash["VI"] = "/" + compoundforbidflag; compoundHash["VIBOE"] = "/" + compoundpermitflag; compoundHash["WI"] = "/" + compoundforbidflag; for(map::iterator it = str_int.begin(); it != str_int.end(); it++) { (*aff_file) << it->second << " "; string tmp = it->first; int t = tmp.find("\t"); if(t == 0) { (*aff_file) << "0"; } else { (*aff_file) << tmp.substr(0,t); } (*aff_file) << compoundHash[tmp.substr(t+1,tmp.size())] << " . " << tmp.substr(t+1,tmp.size()); (*aff_file) << endl; } } string_int::~string_int() { }