本文整理汇总了C++中Hypothesis::print方法的典型用法代码示例。如果您正苦于以下问题:C++ Hypothesis::print方法的具体用法?C++ Hypothesis::print怎么用?C++ Hypothesis::print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hypothesis
的用法示例。
在下文中一共展示了Hypothesis::print方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
SearchSpace::
beamSearch(PhraseTable& pt, Features& weight, int beamsize, int distLimit, int tlimit, bool debug)
{
Hypothesis tmpHypo;
_hypoHeaps[0].push_back(tmpHypo);
Hypothesis& initHypo=_hypoHeaps[0][0];
initHypo.coveredWords.init(_sentence.size(),false);
initHypo.currentScore=0;
initHypo.estimatedScore=0;
initHypo.features.init();
initHypo.lastCoveredWord=-1;
initHypo.represent="";
initHypo.translation.clear();
initHypo.trace.p_prev=NULL;
initHypo.trace.p_rule=NULL;
for(size_t heapIter=0;heapIter<_sentence.size();heapIter++)
{
HypothesisHeap& hHeap=_hypoHeaps[heapIter];
hHeap.sortAndPrune(beamsize);
for(int hypoIter=0;hypoIter<(int)hHeap.size();hypoIter++)
{
Hypothesis& curHypo=hHeap[hypoIter];
if(debug)
{
cout<<"CurHypo ::"<<endl;
curHypo.print(cout);
}
BITVECTOR bvec=curHypo.coveredWords;
int firstUnCovered=bvec.firstFalse();
for(int start=0;start<(int)bvec.size();start++)
{
if(bvec[start]==true)
continue;
for(int stop=start;
stop<(int)bvec.size()&&
bvec[stop]==false&&
(stop<distLimit+firstUnCovered||start==firstUnCovered);
stop++)
{
pair<int,int> phraseSpan=make_pair(start,stop);
string candiPhrase=_auxSpace.queryPhrase(phraseSpan);
vector<PhraseRuleEntry*>* p_rules=pt.queryRulesVec(candiPhrase);
if(p_rules==NULL)continue;
int newLength=heapIter+stop-start+1;
BITVECTOR newBVec;
combine(bvec,phraseSpan,newBVec);
//cout<<"newBVec: "<<newBVec.represent()<<endl;
double futureScore=_auxSpace.queryFutureCost(newBVec);
vector<PhraseRuleEntry*>& rules=*p_rules;
for(size_t rIter=0;rIter<rules.size()&&(int)rIter<tlimit;rIter++)
{
PhraseRuleEntry& rule=*rules[rIter];
Hypothesis newHypo;
newHypo.genFromChild(curHypo,make_pair(start,stop),rule,weight,futureScore);
if(debug)
{
cout<<"newHypo :: "<<endl;
newHypo.print(cout);
}
_hypoHeaps[newLength].addHypothesis(newHypo);
}
}
}
}
}
_hypoHeaps.back().sortAndPrune(beamsize);
if(debug)
{
cout<<"final hHeap"<<endl;
for(size_t i=0;i<_hypoHeaps.back().size();i++){
Hypothesis& hypo=_hypoHeaps.back()[i];
hypo.print(cout);
}
}
}