void cTumkwsaSink::fetchConfig()
{
  cDataSink::fetchConfig();
  
  configfile = getStr("configfile");
  SMILE_DBG(3,"ASR configfile to load = '%s'",configfile);

  printResult = getInt("printResult");
  SMILE_DBG(3,"printResult = %i",printResult);

  queue = new ObsDataQueue(nLAG);
}
int cTumkwsaSink::myTick(long long t)
{
  if (!atkIsSetup) {
    if (!setupATK()) return 0;
  }
  
  SMILE_DBG(4,"tick # %i, passing frame to ASR engine",t);
  cVector *vec= reader->getNextFrame();  //new cVector(nValues+1);
  if (vec == NULL) return 0;
  //else reader->nextFrame();

  long vi = vec->tmeta->vIdx;
  double tm = vec->tmeta->time;

  APacket * p;
  if (makeFeaturePacket(vec->dataF,vec->N-1, (int)(vec->dataF[vec->N-1]), &p)) {
    feChan->PutPacket(*p);
    delete p;
  }

  // tick success?
  int res = 0;
  smileMutexLock(terminatedMtx);
  if (terminated == FALSE) res = 1;
  smileMutexUnlock(terminatedMtx);

  return res;
}
Example #3
0
int cActiveMqSink::myTick(long long t)
{
  if (featureSender == NULL) {
    if (warned==0) {
      SMILE_IERR(1,"the semaine featureSender has not been set (it is NULL!), please check the log output of the semaine components, and check the semaineCfg section in the config file! (this warning will be shown only once, the system will not work!)");
      warned = 1;
    }
    return 0;
  }

  SMILE_DBG(4,"tick # %i, reading value vector:",t);
  cVector *vec= reader->getNextFrame();  //new cVector(nValues+1);
  if (vec == NULL) return 0;
  //else reader->nextFrame();

  long vi = vec->tmeta->vIdx;
  double tm = vec->tmeta->time;

  int n,i;
  n = vec->N;
  if (!featureSender->areFeatureNamesSet()) {
    std::vector<std::string> tumFeatureNames(n);
    for (i=0; i<n; i++) {
      std::string name(vec->fmeta->getName(i)); 
      tumFeatureNames[i] = name;
    }
    //    tumFeatureNames[i]="speaking";
    //      tumFeatureNames[i+1]="seqNr";
    featureSender->setFeatureNames(tumFeatureNames);
  }

  std::vector<float> features(n);
  for (i=0; i<n; i++) {
    features[i] = (float)(vec->dataF[i]);
  }
  //    features[i] = speakingStatus;
  //    features[i+1] = seqNr;
  //    seqNr++;

//printf("about to send\n");
// NOTE: (FIXME) sometimes the activeMq sender hangs here:
//               restarting activeMq helps to solve this problem
//               nevertheless it should be investigated...
  if (meta != NULL) {
    featureSender->sendFeatureVector(features, meta->getTime(), false);
  } else {
    featureSender->sendFeatureVector(features, 0, false);
  }
//printf("after sending\n");

  // tick success
  return 1;
}
Example #4
0
void cLibsvmSink::fetchConfig()
{
  cDataSink::fetchConfig();
  
  filename = getStr("filename");
  SMILE_DBG(3,"filename = '%s'",filename);

  lag = getInt("lag");
  SMILE_DBG(3,"lag = %i",lag);

  append = getInt("append");
  if (append) { SMILE_DBG(3,"append to file is enabled"); }

  timestamp = getInt("timestamp");
  if (append) { SMILE_DBG(3,"printing timestamp attribute (index 1) enabled"); }

  instanceBase = getStr("instanceBase");
  SMILE_DBG(3,"instanceBase = '%s'",instanceBase);

  instanceName = getStr("instanceName");
  SMILE_DBG(3,"instanceName = '%s'",instanceName);
  
  int i;
  nClasses = getArraySize("class");
  classname = (char**)calloc(1,sizeof(char*)*nClasses);
  for (i=0; i<nClasses; i++) {
    const char *tmp = getStr_f(myvprint("class[%i]",i));
    if (tmp!=NULL) classname[i] = strdup(tmp);
  }

  if (isSet("targetNumAll")) {
    targetNumAll = getInt("targetNumAll");
  }
  if (isSet("targetStrAll")) {
    if (nClasses <=0) COMP_ERR("cannt have 'targetStrAll' option if no class names have been defined using the 'class' option! (inst '%s')",getInstName());
    targetNumAll = getClassIndex(getStr("targetStrAll"));
  }
  nInst = getArraySize("targetNum");
  if (nInst > 0) {
    target = (int *)calloc(1,sizeof(int)*nInst);
    for (i=0; i<nInst; i++) {
      target[i] = getInt_f(myvprint("targetNum[%i]",i));
      if (target[i] < 0) COMP_ERR("invalid class index %i for instance %i (in 'targetNum' option of instance '%s')",target[i],i,getInstName());
    }
  } else {
    nInst = getArraySize("targetStr");
    if (nInst > 0) {
      if (nClasses <=0) COMP_ERR("cannt have 'targetStr' option if no class names have been defined using the 'class' option! (inst '%s')",getInstName());
      target = (int *)calloc(1,sizeof(int)*nInst);
      for (i=0; i<nInst; i++) {
        target[i] = getClassIndex(getStr_f(myvprint("targetStr[%i]",i)));
        if (target[i] < 0) COMP_ERR("invalid class index %i for instance %i (from class '%s' in 'targetStr' option of instance '%s')",target[i],i,getStr_f(myvprint("targetStr[%i]",i)),getInstName());
      }
    } else { nInst = 0; }
  }

}
Example #5
0
int cLibsvmSink::myTick(long long t)
{
  if (filehandle == NULL) return 0;

  SMILE_DBG(4,"tick # %i, writing to lsvm file (lag=%i):",t,lag);
  cVector *vec= reader_->getFrameRel(lag);  //new cVector(nValues+1);
  if (vec == NULL) return 0;
  //else reader->nextFrame();

  long vi = vec->tmeta->vIdx;
  double tm = vec->tmeta->time;
  long idx = 1;
  
/*
  if (prname==1) {
    fprintf(filehandle,"'%s',",instanceName);
  } else if (prname==2) {
    fprintf(filehandle,"'%s_%i',",instanceBase,vi);
  }
  */
  // classes: TODO:::
  if ((nClasses > 0)&&(nInst>0)) {  // per instance classes
    if (inr >= nInst) {
      SMILE_WRN(3,"more instances written to LibSVM file (%i), then there are targets available for (%i)!",inr,nInst);
      fprintf(filehandle,"%i ",targetNumAll);
    } else {
      fprintf(filehandle,"%i ",target[inr++]);
    }
  } else {
    fprintf(filehandle,"%i ",targetNumAll);
  }

//  if (number) fprintf(filehandle,"%i:%i ",idx++,vi);
  if (timestamp) fprintf(filehandle,"%i:%f ",idx++,tm);

  
  // now print the vector:
  int i;
  fprintf(filehandle,"%i:%e ",idx++,vec->dataF[0]);
  for (i=1; i<vec->N; i++) {
    fprintf(filehandle,"%i:%e ",idx++,vec->dataF[i]);
  }

  fprintf(filehandle,"%s",NEWLINE);

  // tick success
  return 1;
}
Example #6
0
void cValbasedSelector::fetchConfig()
{
  cDataProcessor::fetchConfig();

  // load all configuration parameters you will later require fast and easy access to here:

  threshold = (FLOAT_DMEM)getDouble("threshold");
  SMILE_DBG(2,"threshold = %f",threshold);

  idx = getInt("idx");
  invert = getInt("invert");
  allowEqual = getInt("allowEqual");
  removeIdx = getInt("removeIdx");

  outputVal = (FLOAT_DMEM)getDouble("outputVal");
  zerovec = getInt("zeroVec");
}
Example #7
0
void cChroma::fetchConfig()
{
  cVectorProcessor::fetchConfig();
  
  octaveSize = getInt("octaveSize");
  SMILE_DBG(2,"octaveSize = %i",octaveSize);

/*
  inverse = getInt("inverse");
  if (inverse) {
    SMILE_DBG(2,"transformFFT set for inverse FFT",inverse);
    inverse = 1;  // sign of exponent
  } else {
    inverse = -1; // sign of exponent
  }
*/

}
Example #8
0
int cCsvSink::myTick(long long t)
{
  if (filehandle == NULL) return 0;

  SMILE_DBG(4,"tick # %i, writing to CSV file (lag=%i):",t,lag);
  cVector *vec= reader_->getFrameRel(lag);  //new cVector(nValues+1);
  if (vec == NULL) return 0;
  //else reader->nextFrame();

  long vi = vec->tmeta->vIdx;
  double tm = vec->tmeta->time;
  
/*
  if (prname==1) {
    fprintf(filehandle,"'%s',",instanceName);
  } else if (prname==2) {
    fprintf(filehandle,"'%s_%i',",instanceBase,vi);
  }
  */
  

  if (number) fprintf(filehandle,"%i%c",vi,delimChar);
  if (timestamp) fprintf(filehandle,"%f%c",tm,delimChar);

  // now print the vector:
  int i;
  for (i=0; i<vec->N-1; i++) {
    // print float as integer if its decimals are zero
    if (vec->dataF[i] == floor(vec->dataF[i])) {
      fprintf(filehandle,"%.0f%c",vec->dataF[i],delimChar);
    } else {
      fprintf(filehandle,"%e%c",vec->dataF[i],delimChar);
    }
  }
  if (vec->dataF[i] == floor(vec->dataF[i])) {
    fprintf(filehandle,"%0.f%s",vec->dataF[i],NEWLINE);
  } else {
    fprintf(filehandle,"%e%s",vec->dataF[i],NEWLINE);
  }
  nWritten_++;

  // tick success
  return 1;
}
int cFunctionalsVecToVec::myConfigureInstance()
{
  int i,j;

  cComponentManager *_compman = getCompMan();
  if (_compman != NULL) {
    int nTp = _compman->getNtypes();
    nFunctTp = 0;
    for (i=0; i<nTp; i++) {
      const char * tp = _compman->getComponentType(i,1);
      if (tp!=NULL) {
        if (!strncmp(tp,"cFunctional",11)&&strcmp(tp,COMPONENT_NAME_CFUNCTIONALSVECTOVEC)) {
           // find beginning "cFunctional" but not our own type (cFunctinals)
          const char *fn = tp+11;
          if (nFunctTpAlloc == nFunctTp) { // realloc:
            functTp = (char **)crealloc( functTp, sizeof(char*)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc );
            functTpI = (int *)crealloc( functTpI, sizeof(int)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc );
            functI = (int *)crealloc( functI, sizeof(int)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc );
            functN = (int *)crealloc( functN, sizeof(int)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc );
            functObj = (cFunctionalComponent **)crealloc( functObj, sizeof(cFunctionalComponent *)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc );
            nFunctTpAlloc += N_BLOCK_ALLOC;
          }
          functTp[nFunctTp] = strdup(fn);
          functTpI[nFunctTp] = i;
          nFunctTp++;
        }
      }
    }
  }
  SMILE_DBG(2,"(inst '%s') found %i cFunctionalXXXX component types.",getInstName(),nFunctTp);

  // fetch enabled functionals list
  nFunctionalsEnabled = getArraySize("functionalsEnabled");
  nFunctValues = 0;
  requireSorted = 0;
  for (i=0; i<nFunctionalsEnabled; i++) {
    const char *fname = getStr_f(myvprint("functionalsEnabled[%i]",i));
    char *tpname = myvprint("cFunctional%s",fname);
    for (j=0; j<nFunctTp; j++) {
      if (!strcmp(functTp[j],fname)) {
        functI[i] = j;
        break;
      }
    }
// TODO: find duplicates in functionalsEnabled Array!!!

    if (j<nFunctTp) {
      // and create corresponding component instances...
        SMILE_DBG(3,"(inst '%s') creating Functional object 'cFunctional%s'.",fname);
        char *_tmp = myvprint("%s.%s",getInstName(),fname);
        cFunctionalComponent * tmp = (cFunctionalComponent *)(_compman->createComponent)(_tmp,tpname);
        free(_tmp);
        if (tmp==NULL) OUT_OF_MEMORY;
        tmp->setComponentEnvironment(_compman, -1, this);
        functN[i] = tmp->getNoutputValues();
        requireSorted += tmp->getRequireSorted();
        nFunctValues += functN[i];
        functObj[i] = tmp;
        //functTp[i]  = strdup(fname);
    } else {
      SMILE_ERR(1,"(inst '%s') Functional object '%s' specified in 'functionalsEnabled' array, however no type 'cFunctional%s' exists!",getInstName(),fname,fname);
      functObj[i] = NULL;
      functN[i] = 0;
      free(tpname);
      return 0;
      //functTp[i]  = NULL;
    }
    free(tpname);
  }
  if (requireSorted)
    SMILE_DBG(2,"%i Functional components require sorted data.",requireSorted);

  return cVectorProcessor::myConfigureInstance();

}
int cCommandlineParser::doParse(int ignDupl, int ignUnknown)
{
  int expectOpt = 1;
  int expectNum = 0;
  int showusage = 0;

  // foreach argv element with(--) or (-), find the thing in opt
  int i,n;
  SMILE_DBG(3,"about to parse %i commandline options ",argc-1);
  for (i=1; i<argc; i++) {
    SMILE_DBG(5,"parsing option %i : '%s'",i,argv[i]);
    if (argv[i][0] == '-') { // option...?
      if ((argv[i][1] == 'h')&&(argv[i][2] == 0)) { // usage (-h)
        showusage = 1;
      } else {
      if (!expectNum) {
        char *o = argv[i]+1;
        if (o[0] == '-') o++;
        n = findOpt(o);
        if (n >= 0) { // found!
          if (opt[n].isSet == 1) { // option specified twice...!
            if (!ignDupl) SMILE_ERR(0,"duplicate option '%s' on commandline (ignoring duplicate!) ",o);
          } else {
          // now look for value....
          if (i+1 < argc) {
            int optCand = 0;
            if (argv[i+1][0] == '-') optCand = 1;  // argument might be an option... or a negative numeric
            int v; double vd; char *o2;
            char *ep = NULL;
            
            // parse value according to type...
            switch (opt[n].type) {
              case CMDOPT_BOOLEAN:
                if (!optCand) {  // explicit value given
                  if ((argv[i][0] == '0')||(argv[i][0] == 'N')||(argv[i][0] == 'n')||(argv[i][0] == 'F')||(argv[i][0] == 'f')) opt[n].dfltInt = 0;
                  else if ((argv[i][0] == '1')||(argv[i][0] == 'Y')||(argv[i][0] == 'y')||(argv[i][0] == 'T')||(argv[i][0] == 't')) opt[n].dfltInt = 1;
                  i++; // next parameter of commandline
                } else {
                  if (opt[n].dfltInt == 0) opt[n].dfltInt = 1;  // invert boolean default, if option is given
                  else opt[n].dfltInt = 0;
                  opt[n].isSet = 1;
                }
                break;
              case CMDOPT_INT:
                //  parse value:
                errno=0;
                v = strtol(argv[i+1],NULL,10); // values base 10... TODO: support hex
                if ( (optCand) && ((v==0)&&(errno==EINVAL)) ) { // option... no value given
                    if (opt[n].argMandatory) COMP_ERR("option '%s' requires an argument!",o);
                    else { opt[n].isSet = 1; }
                } else {
                  if ((v==0)&&(errno==EINVAL)) COMP_ERR("invalid value specified for commandline option '%s'",o);
                  if ((v==0)&&(errno==ERANGE)) COMP_ERR("value specified for commandline option '%s' is out of range",o);
                  opt[n].dfltInt = v;
                  opt[n].dfltDouble = (double)v;
                  opt[n].isSet = 1;
                  i++; // next parameter of commandline
                }
                break;
              case CMDOPT_DOUBLE:
                //  parse value:
                vd = strtod(argv[i+1],&ep);
                if ( (optCand) && ((vd==0.0)&&(ep==argv[i+1])) ) { // option... no value given
                    if (opt[n].argMandatory) COMP_ERR("option '%s' requires an argument!",o);
                    else { opt[n].isSet = 1; }
                } else {
                  if ((vd==0)&&(ep==argv[i+1])) COMP_ERR("invalid value specified for commandline option '%s'",o);
                  //if ((v==0)&&(errno==ERANGE)) COMP_ERR("value specified for commandline option '%s' is out of range",o);
                  opt[n].dfltDouble = vd;
                  opt[n].dfltInt = (int)vd;
                  opt[n].isSet = 1;
                  i++; // next parameter of commandline
                }
                break;
              case CMDOPT_STR:
                if (optCand) {  // bad situation... look for option
                  o2 = argv[i+1]+1;
                  if (o2[0] == '-') o2++;
                  int tmp = findOpt(o2);
                  if (tmp >= 0) { // next option
                    if (opt[n].argMandatory) COMP_ERR("option '%s' requires an argument!",o);
                    else { opt[n].isSet = 1; }
                  } else { // string value
                    i++; // next parameter of commandline
                    if (opt[n].dfltStr != NULL) free(opt[n].dfltStr);
                    opt[n].dfltStr = strdup(argv[i]);
                    opt[n].isSet = 1;
                  }
                } else { // string value
                  i++; // next parameter of commandline
                  if (opt[n].dfltStr != NULL) free(opt[n].dfltStr);
                  opt[n].dfltStr = strdup(argv[i]);
                  opt[n].isSet = 1;
                }
                break;
              default:
                COMP_ERR("unknown option type (%i) encountered... this actually cannot be!",opt[n].type);
            }
          } else {  // no value... check if one is required... 
            if (opt[n].argMandatory) COMP_ERR("option '%s' requires an argument!",o);
            else {
              // process boolean option, if boolean, else ignore...
              if (opt[n].type == CMDOPT_BOOLEAN) {
                if (opt[n].dfltInt == 0) opt[n].dfltInt = 1;  // invert boolean default, if option is given
                else opt[n].dfltInt = 0;
              }
              opt[n].isSet = 1;
            }
          }
          }
        } else {
          if (!ignUnknown) SMILE_ERR(0,"doParse: unknown option '%s' on commandline!",argv[i]);
        }
      } else {
        // parse as number...?
        // not required... not implemented...
      }
      } // if option == -h
    }
  }

  // TODO: from argv[0] get correct 'binname' to pass to showUsage
  if (showusage) {
    showUsage();
    return -1;
  }
  
  // now check if all mandatory parameters have been specified...
  int err = 0;
  for (i=0; i<N; i++) {
    if ( (opt[i].isSet == 0)&&(opt[i].isMandatory == 1) ) { SMILE_ERR(0,"mandatory commandline option '%s' was not specified!",opt[i].name); err = 1; }
  }
  if (err) {
    showUsage();
    SMILE_ERR(0,"missing options on the commandline!");
    return -1;
  }
  
  return 0;
}
Example #11
0
int cLibsvmLiveSink::myTick(long long t)
{
  if (model == NULL) return 0;

  SMILE_DBG(4,"tick # %i, classifiy value vector using LibSVM (lag=%i):",t,lag);
  cVector *vec= reader->getFrameRel(lag);  //new cVector(nValues+1);
  if (vec == NULL) return 0;
//  else reader->nextFrame();

  struct svm_node *x = NULL;
  int i = 0;
  double v;
                                          // need one more for index = -1
  long Nft = Nsel;
  if (Nft <= 0) Nft = vec->N;

  if (fselType) {
    if ((outputSelIdx.enabled == NULL)&&(outputSelStr.names != NULL)) {
      buildEnabledSelFromNames(vec->N, vec->fmeta);
    } else if (outputSelIdx.enabled == NULL) Nft = vec->N;
  }
    
  // TODO: fselection by names... 
  // TODO: compute Nsel in loadSelection

  x = (struct svm_node *) malloc( (Nft + 1) * sizeof(struct svm_node));
  int j = 0;
  for (i=0; i<vec->N; i++) {
    if ((outputSelIdx.enabled == NULL)||(Nsel<=0)) {
      x[i].index = i+1; // FIXME!!! +1 is ok??? (no!?)
      x[i].value = vec->dataF[i];
    } else {
      if (outputSelIdx.enabled[i]) {
        x[j].index = j+1; // FIXME!!! +1 is ok??? (no!?)
        x[j].value = vec->dataF[i];
        j++;
      }
    }
  }
  if ((outputSelIdx.enabled == NULL)||(Nsel<=0)) {
    x[i].index = -1;
    x[i].value = 0.0;
  } else {
    x[j].index = -1;
    x[j].value = 0.0;
  }

  svm_apply_scale(scale,x);

     /*
        for (i=0; i<vec->n; i++) {
          printf("%i:%f ",i,x[i].value);
        }
        printf("\n");
     */
  long vi = vec->tmeta->vIdx;
  double tm = vec->tmeta->smileTime;
  double dur = vec->tmeta->lengthSec;

  if ( (predictProbability) && (svmType==C_SVC || svmType==NU_SVC) ) {
    v = svm_predict_probability(model,x,probEstimates);
    processResult(t, vi, tm, v, probEstimates, nClasses, dur);
//    printf("%g",v);
//    for(j=0;j<nr_class;j++)
//      printf(" %g",prob_estimates[j]);
//    printf("\n");
  } else {
    v = svm_predict(model,x);
    processResult(t, vi, tm, v, NULL, nClasses, dur);
//    result = v;
//    printf("%g\n",v);
  }
  free(x);

/*
	if (svm_type==NU_SVR || svm_type==EPSILON_SVR)
	{
		printf("Mean squared error = %g (regression)\n",error/total);
		printf("Squared correlation coefficient = %g (regression)\n",
		       ((total*sumvy-sumv*sumy)*(total*sumvy-sumv*sumy))/
		       ((total*sumvv-sumv*sumv)*(total*sumyy-sumy*sumy))
		       );
	}
	else
		printf("Accuracy = %g%% (%d/%d) (classification)\n",
		       (double)correct/total*100,correct,total);
  */
  
  


  // tick success
  return 1;
}
Example #12
0
int cArffSink::myTick(long long t)
{
  if (filehandle == NULL) return 0;

  SMILE_DBG(4,"tick # %i, reading value vector (lag=%i):",t,lag);
  cVector *vec= reader_->getFrameRel(lag);  //new cVector(nValues+1);
  if (vec == NULL) return 0;
  //else reader->nextFrame();

  long vi = vec->tmeta->vIdx;
  double tm = vec->tmeta->time;
  double len = vec->tmeta->lengthSec;

  if (vec->tmeta->metadata.iData[1] == 1234) {
    instanceName = vec->tmeta->metadata.text;
    if (prname==1) {
      fprintf(filehandle,"%s,",instanceName);
    }
  } else {
    if (prname==1) {
      fprintf(filehandle,"'%s',",instanceName);
    } else if (prname==2) {
      fprintf(filehandle,"'%s_%i',",instanceBase,vi);
    }
  }

  if (number) fprintf(filehandle,"%i,",vi);
  if (timestamp) fprintf(filehandle,"%f,",tm+frameTimeAdd);
  if (frameLength) fprintf(filehandle,"%f,",len);
  
  // now print the vector:
  int i;
  fprintf(filehandle,"%e",vec->dataF[0]);
  for (i=1; i<vec->N; i++) {
    fprintf(filehandle,",%e",vec->dataF[i]);
    //printf("  (a=%i vi=%i, tm=%fs) %s.%s = %f\n",reader->getCurR(),vi,tm,reader->getLevelName(),vec->name(i),vec->dataF[i]);
  }

  // classes: 
  if ((vec->tmeta->metadata.iData[1] == 1234)&&(vec->tmeta->metadata.custom != NULL)&&(vec->tmeta->metadata.customLength > 0)&&(useTargetsFromMetadata)) {
    // TODO: check the order of the fields....
    fprintf(filehandle, ",%s", (const char *)(vec->tmeta->metadata.custom));
  } else {
    if (nClasses > 0) {
      if (nInst>0) {
        if (inr >= nInst) {
          SMILE_WRN(3,"more instances writte to ARFF file, then there are targets available for (%i)!",nInst);
          if (targetall != NULL) {
            for (i=0; i<nClasses; i++) {
              if (targetall[i] != NULL)
                fprintf(filehandle,",%s",targetall[i]);
              else
                fprintf(filehandle,",NULL");
            }
          } else {
            for (i=0; i<nClasses; i++) {
              fprintf(filehandle,",NULL");
            }
          }
          //inr++;
        } else {
          for (i=0; i<nClasses; i++) {
            fprintf(filehandle,",%s",targetinst[i][inr]);
          }
          inr++;
        }
      } else {
        if (targetall != NULL) {
          for (i=0; i<nClasses; i++) {
            if (targetall[i] != NULL)
              fprintf(filehandle,",%s",targetall[i]);
            else
              fprintf(filehandle,",NULL");
          }
        } else {
          for (i=0; i<nClasses; i++) {
            fprintf(filehandle,",NULL");
          }
        }
      }
    } else {
      // dummy class attribute, always 0
      if (printDefaultClassDummyAttribute) {
        fprintf(filehandle,",0");
      }
    }
  }

  fprintf(filehandle,"%s",NEWLINE);

  int err = fflush(filehandle);
  if (err == EOF) {
    SMILE_IERR(1,"error writing to file '%s' (code: %i)",filename,errno);
    COMP_ERR("aborting");
    return 0;
  }

  nWritten_++;

  // tick success
  return 1;
}