void Feature:: createFTypeTree(FTypeTree* posftTree, int n, int which) { assert(posftTree); if(!posftTree->left) { posftTree->left = new FTypeTree(n); Feature::ftTreeFromInt[which][n] = posftTree->left; } else if(!posftTree->right) { posftTree->right = new FTypeTree(AUXIND); createFTypeTree(posftTree->right, n, which); } else createFTypeTree(posftTree->right, n, which); }
void Feature:: createFTypeTree(FTypeTree* posftTree, int n, int which) { if(!posftTree->left) { posftTree->left = new FTypeTree(n); Feature::ftTreeFromInt[which][n] = posftTree->left; //cerr<< "hanging from " << posftTree->n << " we now have " << n << endl; } else if(!posftTree->right) { posftTree->right = new FTypeTree(AUXIND); createFTypeTree(posftTree->right, n, which); } else createFTypeTree(posftTree->right, n, which); }
void Feature:: init(ECString& path, ECString& conditioned) { assignCalc(conditioned); int f; for(f = 0 ; f < MAXNUMFS ; f++) { float* vec = new float[15]; lambdas_[whichInt][f] = vec; for(int k = 0 ; k < 15 ; k++) vec[k] = 0.0; } ECString dataECString(path); dataECString += "featInfo."; dataECString += conditioned; ifstream dataStrm(dataECString.c_str()); assert(dataStrm); int auxCnts[MAXNUMFS]; int i; for(i = 0 ; i < MAXNUMFS ; i++) auxCnts[i] = 0; Feature::ftTreeFromInt[whichInt][0] = &(Feature::ftTree[whichInt]); int conditionedInt; dataStrm >> conditionedInt; conditionedFeatureInt[whichInt] = conditionedInt; int num; for(num = 0 ; ; num++) { int n, subf, pos, cpr; ECString nm; ECString tmp; dataStrm >> tmp; if(tmp == "--") break; n = atoi(tmp.c_str()); dataStrm >> nm; dataStrm >> subf; dataStrm >> pos; dataStrm >> tmp; if(tmp == "|") cpr = -1; else { cpr = atoi(tmp.c_str()); dataStrm >> tmp; assert(tmp == "|"); } array_[whichInt][n-1] = new Feature(n, nm, subf, pos, cpr); array_[whichInt][n-1]->auxCnt = auxCnts[pos]; auxCnts[pos]++; createFTypeTree(Feature::ftTreeFromInt[whichInt][pos], n, whichInt); } Feature::total[whichInt] = num; for(num = 0 ; ; num++) { int n, fn; ECString nm; ECString tmp; dataStrm >> tmp; if(tmp == "--") break; n = atoi(tmp.c_str()); dataStrm >> nm; dataStrm >> fn; list<int> featList; for( ; ; ) { dataStrm >> tmp; if(tmp == "|") break; int f = atoi(tmp.c_str()); featList.push_back(f); } SubFeature::fromInt(n, whichInt) = new SubFeature(n, nm, fn, featList); assert(SubFeature::fromInt(n, whichInt)); } SubFeature::total[whichInt] = num; /* set the universal function num on feats from their subfeats */ for(num = 0 ; num < Feature::total[whichInt] ; num++) { Feature* f = array_[whichInt][num]; f->usubFeat = SubFeature::fromInt(f->subFeat,whichInt)->usf; } /* set up the table from universal subfeat nums to subfeat nums */ for(num = 0 ; num < MAXNUMFS ; num++) SubFeature::ufArray[whichInt][num] = -1; for(num = 0 ; num < SubFeature::total[whichInt] ; num++) { SubFeature* sf = SubFeature::fromInt(num,whichInt); SubFeature::ufArray[whichInt][sf->usf] = num; } }