src/Generic/names/IdFTrainer.cpp
/**
 * puts the events from this training sentence into _wordEventCounts and _tagEventCounts
 */
puts the events from this training sentence into _wordEventCounts and _tagEventCounts
puts the events from this training sentence into _wordEventCounts and _tagEventCounts
void IdFTrainer::collectSentenceCounts(IdFSentence* sentence) {
	Symbol ngram[8];
	if (sentence->getLength() == 0)
		return;
	for (int i = 0; i < sentence->getLength(); i++) {
		ngram[0] = sentence->getWord(i);
		if (i == 0)
			ngram[1] = FIRSTWORD;
		else ngram[1] = NOTFIRSTWORD;
		ngram[2] = sentence->getFullTag(i);
		ngram[3] = sentence->getReducedTag(i);
		ngram[4] = sentence->getTagStatus(i);
		if (i == 0) {
			ngram[5] = _nameClassTags->getSentenceStartTag();
			ngram[6] = _nameClassTags->getSentenceStartTag();
		} else {
			ngram[5] = sentence->getFullTag(i - 1);
			ngram[6] = sentence->getWord(i - 1);
		}
		if (i <= 1)
			ngram[7] = FIRSTWORD;
		else ngram[7] = NOTFIRSTWORD;
		_wordEventCounts->add(ngram);
		ngram[0] = sentence->getFullTag(i);
		if (i == 0) {
			ngram[1] = _nameClassTags->getSentenceStartTag();
			ngram[2] = _nameClassTags->getSentenceStartTag();
		} else {
			ngram[1] = sentence->getFullTag(i - 1);
			ngram[2] = sentence->getWord(i - 1);
		}
		if (i <= 1)
			ngram[3] = FIRSTWORD;
		else ngram[3] = NOTFIRSTWORD;
		_tagEventCounts->add(ngram);
	}
	ngram[0] = _nameClassTags->getSentenceEndTag();
	ngram[1] = sentence->getFullTag(sentence->getLength() - 1);
	ngram[2] = sentence->getWord(sentence->getLength() - 1);
	if (sentence->getLength() - 1 > 0)
		ngram[3] = NOTFIRSTWORD;
	else ngram[3] = FIRSTWORD;
	_tagEventCounts->add(ngram);
}
void IdFTrainer :: collectSentenceCounts ( IdFSentence * sentence ) { Symbol ngram [ 8 ] ; if ( sentence -> getLength ( ) == 0 ) return ; for ( int i = 0 ; i < sentence -> getLength ( ) ; i ++ ) { ngram [ 0 ] = sentence -> getWord ( i ) ; if ( i == 0 ) ngram [ 1 ] = FIRSTWORD ; else ngram [ 1 ] = NOTFIRSTWORD ; ngram [ 2 ] = sentence -> getFullTag ( i ) ; ngram [ 3 ] = sentence -> getReducedTag ( i ) ; ngram [ 4 ] = sentence -> getTagStatus ( i ) ; if ( i == 0 ) { ngram [ 5 ] = _nameClassTags -> getSentenceStartTag ( ) ; ngram [ 6 ] = _nameClassTags -> getSentenceStartTag ( ) ; } else { ngram [ 5 ] = sentence -> getFullTag ( i - 1 ) ; ngram [ 6 ] = sentence -> getWord ( i - 1 ) ; } if ( i <= 1 ) ngram [ 7 ] = FIRSTWORD ; else ngram [ 7 ] = NOTFIRSTWORD ; _wordEventCounts -> add ( ngram ) ; ngram [ 0 ] = sentence -> getFullTag ( i ) ; if ( i == 0 ) { ngram [ 1 ] = _nameClassTags -> getSentenceStartTag ( ) ; ngram [ 2 ] = _nameClassTags -> getSentenceStartTag ( ) ; } else { ngram [ 1 ] = sentence -> getFullTag ( i - 1 ) ; ngram [ 2 ] = sentence -> getWord ( i - 1 ) ; } if ( i <= 1 ) ngram [ 3 ] = FIRSTWORD ; else ngram [ 3 ] = NOTFIRSTWORD ; _tagEventCounts -> add ( ngram ) ; } ngram [ 0 ] = _nameClassTags -> getSentenceEndTag ( ) ; ngram [ 1 ] = sentence -> getFullTag ( sentence -> getLength ( ) - 1 ) ; ngram [ 2 ] = sentence -> getWord ( sentence -> getLength ( ) - 1 ) ; if ( sentence -> getLength ( ) - 1 > 0 ) ngram [ 3 ] = NOTFIRSTWORD ; else ngram [ 3 ] = FIRSTWORD ; _tagEventCounts -> add ( ngram ) ; }
puts the events from this training sentence into _wordEventCounts and _tagEventCounts
puts the events from this training sentence into _wordEventCounts and _tagEventCounts
// ngram = word, firstword?, tag, reduced-tag, tag-status,
 //         word-minus-1 word-minus-1-firstword?
 // ngram = tag, tag-minus-1, word-minus-1		
 // END (just tag events)
