#include #include #include #include #include using namespace std; struct Instance { string name; bool selected; Instance(const string &name) { selected=false; this->name=name; } }; int main(int argc, char **argv) { if (argc!=2) { cout << "syntax: selection \n"; exit(1); } ifstream in(argv[1]); vector list; string tmp,mode; int nb,total=0; srandom(2017); #define SQL #ifdef SQL ofstream sql("list.sql"); int idevent=88; #endif while(in.good()) { list.clear(); while(in.peek()=='#' || in.peek()=='\n') getline(in,tmp); in >> nb; // number of instances to select; in >> mode; // first or rand getline(in,tmp); if(mode!="first" && mode!="rand") throw runtime_error(string("unexpected mode: ")+mode); if (!in.good()) break; while(in.good()) { getline(in,tmp); if (tmp.length()==0) break; if(tmp[0]=='#') continue; list.push_back(Instance(tmp)); } if(nb>=list.size()) { // select every instance for(size_t i=0;ilist.size()) cout << "## WARNING: not enough instances!\n"; cout << "## " << nb << " " << mode << " instances are selected out of " << list.size() << ":\n"; for(int i=0;i