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


C++ WordList::getWordList方法代码示例

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


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

示例1: replaceNonTerminal

/**
 * replace the given shield with a NonTerminal in the Sequence
 * @param uyv the yield to be replaced
 * @param nonTerminal
 */
void Dencoder::replaceNonTerminal(shared_ptr<UYiV> uyv, int nonTerminal)
{

  int I = nonTerminal-1;

  vector<int> delimiterPos;
  shared_ptr<Word> u = uyv->getU();
  shared_ptr<Word> v = uyv->getV();


  // int uSize = u->getSize();
  int vSize = v->getSize();

  int uPos = -1;
  int vPos = -1;
  int yieldLength = -1;
  int diff = 0;

  //I'm gonna use this just to know which y i'm adding and its position. 
  WordList* y = uyv->getYList();

  list< shared_ptr<Word> > * wordList = y->getWordList();
  list< shared_ptr<Word> >::iterator yIt = wordList->begin();

  int p, k, l, total;
  p = uyv->getWordsPosPairs()->size();
  k = uyv->getU()->getSize();
  l = uyv->getV()->getSize();

  // if(opt == 0)
  // total = getSeq()->getSize() - (p*k + p*l + y->sumWordsLengthWithRepeats() - p);
  // else
  
  total = getSeq()->getSize() - (p*k + p*l + y->sumWordsLengthWithRepeats() - p) ;


  int * newSeq = new int[total];

  shared_ptr<Sequence> oldSequence = getSeq();
  int realSize = oldSequence->getSize();

  int* oldSeq = oldSequence->getIntSequence();


  list<std::pair<int, int> > * wordsPosPairs = uyv->getWordsPosPairs();
  list<std::pair<int,int> >::iterator posIt = wordsPosPairs->begin();

  int lastEncode = -2;
  assert(lastEncode!=-15); 
  int yWordPos;

  //Rewrite
    
  for(int i = 0; i < realSize; i++)
  {
    assert(i<oldSequence->getSize());
    assert(i-diff<total);

    if (posIt!=wordsPosPairs->end() && i == (*posIt).first)
    {
      uPos = (*posIt).first;
      vPos = (*posIt).second;


      //add which production option I chose here
      yWordPos = y->wordPos(*yIt);
      prodElectionOrder_[I].push(yWordPos);
      totalElectionSize_++;
      // Changes for the new encode:
      ++yIt; 
      

      yieldLength = vPos + vSize - uPos;
      
      newSeq[i - diff] = nonTerminal;
      diff += yieldLength-1;
      i += yieldLength-1;

      //increase pos iterator
      posIt++;
    }
    else
    {
      if(oldSeq[i] == 1)
        {
          delimiterPos.push_back(i-diff);
        }
      newSeq[i-diff] = oldSeq[i];
    }
  }
  //Create Productions:
  list<shared_ptr<Production> >* lp;
  lp = rebuildGrammar(newSeq, delimiterPos, total);
  delete[] newSeq;
  grammar_ = make_shared<Grammar>(lp);
//.........这里部分代码省略.........
开发者ID:frandorr,项目名称:Stage,代码行数:101,代码来源:Dencoder.cpp


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