/**
 * \brief Constructor.
 */
tunnel::player_pending_action::player_pending_action( const std::string & str )
{
  std::vector<std::string> params;
  
  claw::text::split(params, str, '|');
  if ( params.size() == 5 ) 
    {
      size_t t;
      std::istringstream iss0(params[0]);
      iss0 >> t;
      if ( t == start_action ) 
	pending_type = start_action;
      else if ( t == stop_action ) 
	pending_type = stop_action;
      else
	pending_type = do_action;
      
      std::istringstream iss1(params[1]);
      iss1 >> date; 
      
      std::istringstream iss2(params[2]);
      iss2 >> player_index; 
      
      std::istringstream iss3(params[3]);
      iss3 >> action; 
      
      std::istringstream iss4(params[4]);
      iss4 >> duration;
    }
Exemple #2
0
int TestFullModel::LoadInstanceInit(ifstream &ifs) {
    int id;
    int fea_id;
    int beg1 = 0, end1 = 0, beg2 = 0, end2 = 0;
    char line_buf[5000], line_buf2[1000];
    vector<int> trigram_id;
    trigram_id.resize(3);
    ifs.getline(line_buf, 1000, '\n');
    if (!strcmp(line_buf, "")) {
        return 0;
    }
    ((LrFcemInstance*) inst) -> Clear();
    {
        istringstream iss(line_buf);
        iss >> inst -> label;
        feat2int::iterator iter = labeldict.find(inst -> label);
        if (iter == labeldict.end()) {
            id = (int)labeldict.size();
            //            cout << inst->label << endl;
            labeldict[inst -> label] = id;
        }
        
        iter = lab_model -> vocabdict.find(inst -> label);
        if (iter == lab_model -> vocabdict.end()) {
            id = (int)lab_model -> vocabdict.size();
            lab_model -> vocabdict[inst -> label] = id;
        }
        
        iss >> beg1; iss >> end1;
        inst -> ne1_len = end1 + 1 - beg1;
        for (int i = 0; i < inst -> ne1_len; i++) {
            iss >> inst -> ne1_words[i];
            ToLower(inst -> ne1_words[i]);
        }
        iss >> beg2; iss >> end2;
        inst -> ne2_len = end2 + 1 - beg2;
        for (int i = 0; i < inst -> ne2_len; i++) {
            iss >> inst -> ne2_words[i];
            ToLower(inst -> ne2_words[i]);
        }
    }
    {
        ifs.getline(line_buf, 5000, '\n');
        {
            ifs.getline(line_buf2, 1000, '\n');
            istringstream iss3(line_buf2);
            int tmpint;
            string ne_tag;
            iss3 >> tmpint;
            for (int i = 0; i < inst -> ne1_len; i++) {
                iss3 >> inst -> ne1_types[i];
                inst -> ne1_types[i] = ProcSenseTag(inst -> ne1_types[i]);
                if(fea_params.ner) {
                    iss3 >> ne_tag;
                    inst -> ne1_nes[i] = ProcNeTag(ne_tag);
                }
            }
        }
        {
            ifs.getline(line_buf2, 1000, '\n');
            istringstream iss4(line_buf2);
            int tmpint;
            string ne_tag;
            iss4 >> tmpint;
            for (int i = 0; i < inst -> ne2_len; i++) {
                iss4 >> inst -> ne2_types[i];
                inst -> ne2_types[i] = ProcSenseTag(inst -> ne2_types[i]);
                if (fea_params.ner) {
                    iss4 >> ne_tag;
                    inst -> ne2_nes[i] = ProcNeTag(ne_tag);
                }
            }
        }
Exemple #3
0
void define_data(IloEnv env) {
  string line("           ");
  ifstream myfile ("/home/DavidRC/data.txt");
  int i=0;
  int j=0;
  int x=0;
  int y=0;

  if (myfile.is_open())
  {
    i=0;
	  j=0;
    
	  getline(myfile,line);
	  n=atoi(line.c_str());
	  IloNumArray l(env,n);
	  NumMatrix w(env,n);
    
    for(i=0; i<n; i++)
    {
      w[i]=IloNumArray(env,n);
    }
	  
	  getline (myfile,line);
    
	  istringstream iss1(line);  
	  	while (iss1 && j<n) 
		{ 
			string subs; 
			iss1 >> subs; 
			string temp=subs;
			if(temp.compare("")==0)
			{
				continue;
			}
			else
			{

            l[j]=atoi(subs.c_str());
			}
			j++;
	    }
     exit(1);

     i=0;
	 j=0;
	 while ( getline (myfile,line) && i<n)
     {
	    istringstream iss2(line);
          j=0;

		while (iss2 && j<n) 
		{ 
			string subs; 
			iss2 >> subs; 
			string temp=subs;

			if(temp.compare("")==0)
			{
				continue;
                        j++;
			}
			else
			{

            w[i][j]=atoi(subs.c_str());
            			j++;
			}
	    }
		i++;
    }

	  m=atoi( line.c_str() );

    IloNumArray c(env,m);
	  NumMatrix d(env,m);
    
    for(i=0; i<m; i++)
    {
      d[i]=IloNumArray(env,m);
    } 
		  
  i=0;
  j=0;    
	getline (myfile,line);
	istringstream iss3(line);
	while (iss3 && j<m) 
	{ 
		string subs; 
		iss3 >> subs; 
		string temp=subs;
		if(temp.compare("")==0)
		{
			continue;
		}
		else
		{
           c[j]=atoi(subs.c_str());
		}
		j++;
	}
		
	i=0;
	j=0;
	while ( getline (myfile,line) && i<m)
    {
	    istringstream iss4(line);
          j=0;
		while (iss4 && j<m) 
		{ 
			string subs; 
			iss4 >> subs; 
			string temp=subs;
			if(temp.compare("")==0)
			{
				continue;
			}
			else
			{
            d[i][j]=atoi(subs.c_str());
			}
			j++;
	    }
		i++;
    }
    myfile.close();
  }