本文整理汇总了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);
//.........这里部分代码省略.........