bool bilCorpus::getNextSentPair (sentPair & sp, vocTable & svoc, vocTable & tvoc, int sInputType,int tInputType, vocTable & sTagVoc, vocTable & tTagVoc){
  sp.clear();
  ++sentPairNum;
  if (!untilEnd && sentPairNum>lastSentPairNum){
    return false;
  }
  string line;
  sp.nlevels=fsFile.size();
  sp.initPhToWdMaps();
  for (vector<ifstream*>::size_type nf=0; nf<fsFile.size();++nf){
    if (! fsFile[nf]->good()){
      return false;
    }else{
      // read source sentence and split it
      if (sInputType==0){
	if (nf==0 && getline(*fsFile[nf],line)) sp.loadSrcWords(line,svoc);
	else if (getline(*fsFile[nf],line)) sp.loadSrcPhrases(line,nf);
	else  return false;
      }else if (sInputType==1){
	if (nf==0){
	  vector<string> lines;
	  string buf;
	  int stop=-1;
	  int filepos;
	  while (getline(*fsFile[nf],line) && stop <=0){
	    buf=""; //if buf is not reset and "line" is empty, buf keeps its previous value
	    istringstream iss(line);
	    iss >> buf;
	    if (buf == "align"){lines.push_back(line);}
	    if (buf == "name"){++stop;}
	    else {filepos=fsFile[nf]->tellg();}
	  }
	  fsFile[nf]->seekg(filepos);
	  //	  for (vector<string>::const_iterator it=lines.begin();it!=lines.end();++it){cout<<"l:"<<*it<<endl;}
	  sp.loadSrcWords(lines,svoc);
	  //	  cout<<sp.src().print()<<endl;
	  //cout<<sp.srcAlUnits().print()<<endl;
	}else {sp.loadSrcPhrases(line,nf);}
      }
    }