当前位置: 首页>>代码示例>>C++>>正文


C++ StringTokenizer::countTokens方法代码示例

本文整理汇总了C++中StringTokenizer::countTokens方法的典型用法代码示例。如果您正苦于以下问题:C++ StringTokenizer::countTokens方法的具体用法?C++ StringTokenizer::countTokens怎么用?C++ StringTokenizer::countTokens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringTokenizer的用法示例。


在下文中一共展示了StringTokenizer::countTokens方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkNumberTokens

void Tree::checkNumberTokens( StringTokenizer& str, const int& n,
			      const string& tag, const int& ln )
{
  if( n != str.countTokens() ) 
    {
      cerr << "The input-file seems corrupt for the " << Node::getAlphabetName() << " alphabet, line: " << ln << endl << tag << " ";
      cerr << "Line has " << str.countTokens()+1 << " space separated words, should have: " << n + 1 << endl;
      while( str.hasMoreTokens() )cout << str.nextToken() << " ";
      cout << endl;
      exit( 2 ); // THROW EXCEPTION!!
    }
}
开发者ID:ddalevi,项目名称:PSTk-Classifier,代码行数:12,代码来源:Tree.cpp

示例2: StringTokenizer

 opennlp::model::Event *FileEventStream::next()
 {
   StringTokenizer *st = new StringTokenizer(line);
   std::string outcome = st->nextToken();
   int count = st->countTokens();
   std::string context[count];
   for (int ci = 0; ci < count; ci++)
   {
     context[ci] = st->nextToken();
   }
   return (new Event(outcome, context));
 }
开发者ID:benlm54,项目名称:myassist-repo,代码行数:12,代码来源:FileEventStream.cpp

示例3: simplex_construction

void simplex_construction(HDescrMessage *mesg, int client_socket)
{
    // Assumption: The string message is of the form :
    //    radius point
    //    [if different radii]: radius1:radius2:...

    // first get the query string
    char* temp = (char *) malloc(strlen(mesg->get_descr())+10);
    strcpy(temp, mesg->get_descr());
    printf("simplex construction :::: got the request point: %s \n", temp);
    string str_point(temp);
    StringTokenizer strtok(str_point, " ");
    //string r_str = strtok.nextToken();
    int radii[num_groups];
    int radius=1;

    // use different scaling?
    if(use_diff_radius == 1)
    {
        string r_str = strtok.nextToken();
        StringTokenizer radtok (r_str, ":");
        if(radtok.countTokens() != num_groups) {
            fprintf(stderr, "not enough radius values \n");
        } else {
            for(int i = 0; i < num_groups; i++)
            {
                radii[i]=radtok.nextIntToken();
            }
        }
    } else {
        radius = strtok.nextIntToken();
    }
    printf("radius: %d \n", radius);
    string remaining    = strtok.remainingString();
    cout << "remaining: ";
    cout << remaining;
    cout << "\n";

    // first make sure the given init_point is a valid point : make a call
    // to projection function : could move this to a new routine later on
    vec_of_intvec vec_of_vec = get_vectors(remaining);
    string projected_init_point="";
    for(int i=0; i < num_groups; i++) {
        int temp_dim=group_info[i];
        vector<int> temp_vector = vec_of_vec.at(i);
        ANNpoint point = make_point_from_vector(temp_vector,temp_dim);
        if(!is_valid(trees.at(i),temp_vector, temp_dim))
        {
            projected_init_point += get_neighbor(trees.at(i),point,nn_num[i]);
        }
        else
        {
            projected_init_point += vector_to_string(temp_vector);
        }
    }
    cout << "Init Point projected from " << remaining << " to " << projected_init_point << "\n";

    // now constructed the simplex around the projected point
    vec_of_vec = get_vectors(projected_init_point);
    string return_string = "\n global init__ \n set init__ [list ";
    for(int i=0; i < num_groups; i++)
    {
        int temp_dim=group_info[i];
        vector<int> temp_vector = vec_of_vec.at(i);
        ANNpoint init_point = make_point_from_vector(temp_vector, temp_dim);
        if(use_diff_radius)
        {
            return_string += get_neighbor_at_dist(trees.at(i), radii[i], init_point, nn_num[i], i);
        } else
        {
            return_string += get_neighbor_at_dist(trees.at(i), radius, init_point, nn_num[i], i);
        }
    }
    return_string+="]";

    cout << "Initial Simplex Possible points:: " << return_string << "\n";
    char *char_star;
    char_star = new char[return_string.length() + 1];
    strcpy(char_star, return_string.c_str());
    //FILE * pFile;
    FILE *pFile;
    pFile = fopen ("/hivehomes/tiwari/tutorial-2010/harmony/bin/constructed_simplex.tcl","w");
    if (pFile!=NULL)
    {
        fputs (char_star,pFile);
        fclose (pFile);
    }
    HDescrMessage *mesg_desr=new HDescrMessage(HMESG_SIM_CONS_RESULT,char_star,strlen(char_star));
    send_message(mesg_desr, client_socket);
    delete mesg_desr;
    delete [] char_star;
}
开发者ID:jonfetterdegges,项目名称:activeharmony,代码行数:92,代码来源:pserver.c


注:本文中的StringTokenizer::countTokens方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。