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


C++ Converter::to_string方法代码示例

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


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

示例1: main

int main (void) {
  string text_dirpath = string("/Users/KimKR/Desktop/NEXT_LAB/keyword/test");
  string relscore_path = string("/Users/KimKR/Desktop/NEXT_LAB/keyword/rel_score/test/bm25_3_3");
  vector<string> textfiles = vector<string>();
  getdir(text_dirpath, textfiles);
  int winsize = 2;
  int cutoff_list[] = {3};
  int cutoff_size = 1;
  double lambda_list[1];
  int lambda_size = 1;
  Converter cv;
  Print print;
 //  for(int i = 0; i < 21; ++i) {
	// lambda_list[i] = i * 0.05;
 //  }
  lambda_list[0] = 0.85;
  clock_t all_begin = clock();
  for(int fidx = textfiles.size() - 1; fidx >= 0; --fidx) {
    string filename = textfiles[fidx];
    vector<string> sentences = TextRead(text_dirpath + "/" + filename);
    clock_t begin = clock();
    for(int k = K_STR; k < K_STEP; ++k) {
      double k1 = k * 0.1;
      for(int b1 = 0; b1 < 1; ++b1) {
        double b = 0.05 * b1;
        string relfile_path = relscore_path + "_" + cv.to_string(k1, 2) + "_" + cv.to_string(b, 3) + "/" + filename;
        map<string, double> relscore;
        if(RelscoreRead(relfile_path, &relscore) == 0) continue;
        BuildGraph bg(filename, sentences, &relscore, winsize, k1, b, lambda_list, lambda_size, cutoff_list, cutoff_size);
        Graph G;
        G.null_ = true;
        bg.run(true, false, false, false);
        print.Vector("top_score_candidates", bg.top_score_candidates_.at(3).at(0.85));
        SaveGraph(bg.top_score_candidates_, bg.filename_, bg.k1_, bg.b_, bg.winsize_);
      }
    }
    clock_t end = clock();

    double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
    cout << filename << " : " << elapsed_secs << endl;
  }
  clock_t end = clock();
  double elapsed_secs = double(end - all_begin) / CLOCKS_PER_SEC;
  cout << "all finished" << " : " << elapsed_secs << endl;
  getchar();
}
开发者ID:kimkr,项目名称:keyword_extraction,代码行数:46,代码来源:graph.cpp

示例2: SaveGraph

void SaveGraph(const map<int, map<double, vector<string> > >& candidates, const string& filename, 
			   double k1_input, double b_input, int winsize_input) {
  Converter cv;
  string winsize = to_string(winsize_input);
  string k1 = cv.to_string(k1_input, 2);
  string b = cv.to_string(b_input, 3);
  string dirpath = "../graph/" + k1 + "_" + b;
  string filepath = dirpath  + "/" + filename + ".csv";
  string header = "winsize,cutoff,lambda,keywords_candidates\n";
  // CreateDirectory(dirpath);
  if(!FileExists(filepath)) FileWrite(filepath, header);
  ofstream out(filepath, ios_base::app | ios_base::out);
  for(auto itr = candidates.begin(); itr != candidates.end(); ++itr) {
    int cutoff = itr->first;
    map<double, vector<string> > lamb_candidate = itr->second;
    for (auto j = lamb_candidate.begin(); j != lamb_candidate.end(); ++j) {
      double lambda = j->first;
      cout << candidates.at(cutoff).at(lambda)[0] << endl;
      string keywords_candidates = Join(candidates.at(cutoff).at(lambda), ';');
      out << winsize + "," + to_string(cutoff) + "," + cv.to_string(lambda, 3) + "," + keywords_candidates + "\n";
    }
  }
};
开发者ID:kimkr,项目名称:keyword_extraction,代码行数:23,代码来源:graph.cpp


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