Exemplo n.º 1
0
void loadLabelPosition( std::vector< std::string > & labels,
                        std::vector<unsigned>& ids,
                        std::vector< int >& positions,
                        const std::string& infile )  {
  std::ifstream labPosFile(infile.c_str());
  if (!labPosFile) return;
  std::vector<std::string>().swap(labels); //lab2Pos.clear();
  std::vector<int>().swap(positions); //.clear();
  utility::CSVIterator<std::string> labPosLine(labPosFile);// ++labPosLine;
  for( ; labPosLine != utility::CSVIterator<std::string>(); ++labPosLine ) {    
    std::string label =  (*labPosLine)[2];
    int position = boost::lexical_cast<int>( (*labPosLine)[3]);
    unsigned id = boost::lexical_cast<unsigned>( (*labPosLine)[1]);
    ids.push_back(id);
    labels.push_back(label);
    positions.push_back(position);
  }

  std::cout << "load " << labels.size() << " variables.\n";
}
Exemplo n.º 2
0
 // Format LP_ID = 0, LP_LABEL, LP_POSITION
LabPosMap FLTMGraphReader::readLabPos( const std::string labPosFileName ) const {
  LabPosMap lpMap;
  std::ifstream labPosFile(labPosFileName.c_str());
  CSVIterator<std::string> labPosLine(labPosFile);

  ++labPosLine;
  for( ; labPosLine != CSVIterator<std::string>(); ++labPosLine ) {
    int position; std::string label; size_t id;
    // if (labPosLine->size() == 4) {
    //   id = boost::lexical_cast<size_t>( (*labPosLine)[LP_ID] );
    //   label = (*labPosLine)[LP_LABEL] ;
    //   position = boost::lexical_cast<int>( (*labPosLine)[LP_POSITION] );
    // } else {
    //   id = boost::lexical_cast<size_t>( (*labPosLine)[LP_ID+1] );
    //   label = (*labPosLine)[LP_LABEL+1] ;
    //   position = boost::lexical_cast<int>( (*labPosLine)[LP_POSITION+1] );
    // }
    id = boost::lexical_cast<size_t>( (*labPosLine)[0] );
    label = (*labPosLine)[1] ;
    position = boost::lexical_cast<int>( (*labPosLine)[3] );
    lpMap[id] = std::pair<std::string, int>(label, position);
  }
  return lpMap;
}