本文整理汇总了C++中CStateItem::size方法的典型用法代码示例。如果您正苦于以下问题:C++ CStateItem::size方法的具体用法?C++ CStateItem::size怎么用?C++ CStateItem::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStateItem
的用法示例。
在下文中一共展示了CStateItem::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: work
void CDepParser::work( const bool bTrain , const CTwoStringVector &sentence , CDependencyParse *retval , const CDependencyParse &correct , int nBest , SCORE_TYPE *scores ) {
#ifdef DEBUG
clock_t total_start_time = clock();
#endif
static int index;
const int length = sentence.size() ;
const CStateItem *pGenerator ;
static CStateItem pCandidate(&m_lCache) ;
// used only for training
static bool bCorrect ; // used in learning for early update
static bool bContradictsRules;
static CStateItem correctState(&m_lCache) ;
static CPackedScoreType<SCORE_TYPE, action::MAX> packed_scores;
ASSERT(length<MAX_SENTENCE_SIZE, "The size of the sentence is larger than the system configuration.");
TRACE("Initialising the decoding process...") ;
// initialise word cache
bContradictsRules = false;
m_lCache.clear();
for ( index=0; index<length; ++index ) {
m_lCache.push_back( CTaggedWord<CTag, TAG_SEPARATOR>(sentence[index].first , sentence[index].second) );
// filter std::cout training examples with rules
if (bTrain && m_weights->rules()) {
// the root
if ( correct[index].head == DEPENDENCY_LINK_NO_HEAD && canBeRoot(m_lCache[index].tag.code())==false) {
TRACE("Rule contradiction: " << m_lCache[index].tag.code() << " can be root.");
bContradictsRules = true;
}
// head left
if ( correct[index].head < index && hasLeftHead(m_lCache[index].tag.code())==false) {
TRACE("Rule contradiction: " << m_lCache[index].tag.code() << " has left head.");
bContradictsRules = true;
}
// head right
if ( correct[index].head > index && hasRightHead(m_lCache[index].tag.code())==false) {
TRACE("Rule contradiction: " << m_lCache[index].tag.code() << " has right head.");
bContradictsRules = true;
}
}
}
// initialise agenda
m_Agenda->clear();
pCandidate.clear(); // restore state using clean
m_Agenda->pushCandidate(&pCandidate); // and push it back
m_Agenda->nextRound(); // as the generator item
if (bTrain) correctState.clear();
// verifying supertags
if (m_supertags) {
ASSERT(m_supertags->getSentenceSize()==length, "Sentence size does not match supertags size");
}
#ifdef LABELED
unsigned long label;
m_lCacheLabel.clear();
if (bTrain) {
for (index=0; index<length; ++index) {
m_lCacheLabel.push_back(CDependencyLabel(correct[index].label));
if (m_weights->rules() && !canAssignLabel(m_lCache, correct[index].head, index, m_lCacheLabel[index])) {
TRACE("Rule contradiction: " << correct[index].label << " on link head " << m_lCache[correct[index].head].tag.code() << " dep " << m_lCache[index].tag.code());
bContradictsRules = true;
}
}
}
#endif
// skip the training example if contradicts
if (bTrain && m_weights->rules() && bContradictsRules) {
std::cout << "Skipping training example because it contradicts rules..." <<std::endl;
return;
}
TRACE("Decoding started");
// loop with the next word to process in the sentence
for (index=0; index<length*2; ++index) {
if (bTrain) bCorrect = false ;
// none can this find with pruning ???
if (m_Agenda->generatorSize() == 0) {
WARNING("parsing failed");
return;
}
pGenerator = m_Agenda->generatorStart();
// iterate generators
for (int j=0; j<m_Agenda->generatorSize(); ++j) {
// for the state items that already contain all words
m_Beam->clear();
packed_scores.reset();
getOrUpdateStackScore( pGenerator, packed_scores, action::NO_ACTION );
if ( pGenerator->size() == length ) {
assert( pGenerator->stacksize() != 0 );
if ( pGenerator->stacksize()>1 ) {
//.........这里部分代码省略.........