本文整理汇总了C++中CStateItem::StandardFinish方法的典型用法代码示例。如果您正苦于以下问题:C++ CStateItem::StandardFinish方法的具体用法?C++ CStateItem::StandardFinish怎么用?C++ CStateItem::StandardFinish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStateItem
的用法示例。
在下文中一共展示了CStateItem::StandardFinish方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: work
//.........这里部分代码省略.........
#endif
( pGenerator->stackempty() || m_supertags == 0 || m_supertags->canShift( pGenerator->size() ) ) && // supertags
( pGenerator->stackempty() || !m_weights->rules() || canBeRoot( m_lCache[pGenerator->size()].tag.code() ) || hasRightHead(m_lCache[pGenerator->size()].tag.code()) ) // rules
) {
shift(pGenerator, packed_scores) ;
}
}
if ( !pGenerator->stackempty() ) {
if (
#ifndef FRAGMENTED_TREE
( pGenerator->size() < length-1 || pGenerator->headstacksize() == 1 ) && // one root
#endif
( m_supertags == 0 || m_supertags->canArcRight(pGenerator->stacktop(), pGenerator->size()) ) && // supertags conform to this action
( !m_weights->rules() || hasLeftHead(m_lCache[pGenerator->size()].tag.code()) ) // rules
) {
arcright(pGenerator, packed_scores) ;
}
}
if ( (!m_bCoNLL && !pGenerator->stackempty()) ||
(m_bCoNLL && pGenerator->stacksize()>1) // make sure that for conll the first item is not popped
) {
if ( pGenerator->head( pGenerator->stacktop() ) != DEPENDENCY_LINK_NO_HEAD ) {
reduce(pGenerator, packed_scores) ;
}
else {
if ( (m_supertags == 0 || m_supertags->canArcLeft(pGenerator->size(), pGenerator->stacktop())) && // supertags
(!m_weights->rules() || hasRightHead(m_lCache[pGenerator->stacktop()].tag.code())) // rules
) {
arcleft(pGenerator, packed_scores) ;
}
}
}
}
// insert item
for (unsigned i=0; i<m_Beam->size(); ++i) {
pCandidate = *pGenerator;
pCandidate.score = m_Beam->item(i)->score;
pCandidate.Move( m_Beam->item(i)->action );
m_Agenda->pushCandidate(&pCandidate);
}
if (bTrain && *pGenerator == correctState) {
bCorrect = true ;
}
pGenerator = m_Agenda->generatorNext() ;
}
// when we are doing training, we need to consider the standard move and update
if (bTrain) {
#ifdef EARLY_UPDATE
if (!bCorrect) {
TRACE("Error at the "<<correctState.size()<<"th word; total is "<<correct.size())
updateScoresForStates(m_Agenda->bestGenerator(), &correctState, 1, -1) ;
#ifndef LOCAL_LEARNING
return ;
#else
m_Agenda->clearCandidates();
m_Agenda->pushCandidate(&correctState);
#endif
}
#endif
if (bCorrect) {
#ifdef LABELED
correctState.StandardMoveStep(correct, m_lCacheLabel);
#else
correctState.StandardMoveStep(correct);
#endif
}
#ifdef LOCAL_LEARNING
++m_nTrainingRound; // each training round is one transition-action
#endif
}
m_Agenda->nextRound(); // move round
}
if (bTrain) {
correctState.StandardFinish(); // pop the root that is left
// then make sure that the correct item is stack top finally
if ( *(m_Agenda->bestGenerator()) != correctState ) {
TRACE("The best item is not the correct one")
updateScoresForStates(m_Agenda->bestGenerator(), &correctState, 1, -1) ;
return ;
}
}
TRACE("Outputing sentence");
m_Agenda->sortGenerators();
for (int i=0; i<std::min(m_Agenda->generatorSize(), nBest); ++i) {
pGenerator = m_Agenda->generator(i) ;
if (pGenerator) {
pGenerator->GenerateTree( sentence , retval[i] ) ;
if (scores) scores[i] = pGenerator->score;
}
}
TRACE("Done, the highest score is: " << m_Agenda->bestGenerator()->score ) ;
TRACE("The total time spent: " << double(clock() - total_start_time)/CLOCKS_PER_SEC) ;
}