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


C++ mrs_string::begin方法代码示例

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


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

示例1: f

bool
TimeLine::load(mrs_string filename, mrs_string lexicon_labels)
{

  ifstream in;
  filename_ = filename;

  if(filename == "")
    return false;

  in.open(filename.c_str());
  if(!in.is_open())
  {
    MRSWARN("TimeLine::load() -  Problem opening file " << filename_);
    return false;
  }

  FileName f(filename);
  vector<mrs_string> labels;



  // Load lexicon dictionary if available
  mrs_string lexicon_label;
  mrs_string remainder;
  size_t nLabels;

  nLabels = std::count(lexicon_labels.begin(), lexicon_labels.end(), ',');

  if (lexicon_labels != ",")
  {
    for (size_t i=0; i < nLabels; i++)
    {
      lexicon_label = lexicon_labels.substr(0, lexicon_labels.find(","));
      labels.push_back(lexicon_label);
      sort(labels.begin(), labels.end());
      remainder = lexicon_labels.substr(lexicon_labels.find(",") + 1, lexicon_labels.length());
      lexicon_labels = remainder;
    }
  }
  else
    nLabels = 0;


  if (f.ext() == "txt") // audacity label format
  {
    numRegions_ = 0;
    mrs_real start, end;
    mrs_string label;
    regions_.clear();
    while (!in.eof())
    {
      in >> start >> end >> label;


      TimeRegion region;
      region.start = (mrs_natural) (start * srate_);
      region.end = (mrs_natural) (end * srate_);
      region.classId = 1;
      region.name = label;
      mrs_bool label_found = false;

      for (unsigned int i=0; i < labels.size(); i++)
      {
        if (label == labels[i])
        {
          label_found = true;
          region.classId = i;
        }

      }
      if (!label_found)
      {

        if (lexicon_labels == ",")
        {
          labels.push_back(label);
          sort(labels.begin(), labels.end());
        }
      }
      regions_.push_back(region);
      numRegions_ ++;
    }




    // relabel classIds so that they correspond to sorted labels
    for (mrs_natural i=0; i < numRegions_; ++i)
    {
      mrs_string label = regions_[i].name;
      vector<mrs_string>::iterator it = find(labels.begin(), labels.end(), label);
      if (it == labels.end())
        regions_[i].classId = (mrs_natural)-1;
      mrs_natural l = distance(labels.begin(), it);
      regions_[i].classId = l;
    }


    // last region is a duplicate due to empty last line
//.........这里部分代码省略.........
开发者ID:Amos-zq,项目名称:marsyas,代码行数:101,代码来源:TimeLine.cpp


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