src/Chinese/descriptors/ch_DescClassModifiers.cpp
//Calculate the PreModifier portion of the Descriptor Classifier Score

Calculate the PreModifier portion of the Descriptor Classifier Score
Calculate the PreModifier portion of the Descriptor Classifier Score
double ChineseDescClassModifiers::getModifierScore(const SynNode* node, Symbol proposedType){
	Symbol premodVector[3];
	Symbol premodBackoffVector[2];
	Symbol headWord = node->getHeadWord();
	premodVector[0] = proposedType;
	premodBackoffVector[0] = proposedType;
	premodVector[1] = headWord;
	double premod_score = 0;
	int headIndex = node->getHeadIndex();
	for (int j = 0; j < headIndex; j++) {
		premodVector[2] = premodBackoffVector[1] = node->getChild(j)->getHeadWord();
		double frontProb = exp(_modModel->getProbability(premodVector));
		double frontLambda = _modModel->getIncorrectLambda(premodVector);
		double backProb = exp(_modBackoffModel->getProbability(premodBackoffVector));
		double backLambda = _modBackoffModel->getIncorrectLambda(premodBackoffVector);
		double combined_score = (frontLambda*frontProb)+ 
			((1.0-frontLambda)*((backLambda*backProb) + 
			((1.0-backLambda)* 1.0/_VOCAB_SIZE)));
		premod_score += combined_score == 0 ? _LOG_OF_ZERO : log(combined_score);
	}
	return premod_score;
}
double ChineseDescClassModifiers :: getModifierScore ( const SynNode * node , Symbol proposedType ) { Symbol premodVector [ 3 ] ; Symbol premodBackoffVector [ 2 ] ; Symbol headWord = node -> getHeadWord ( ) ; premodVector [ 0 ] = proposedType ; premodBackoffVector [ 0 ] = proposedType ; premodVector [ 1 ] = headWord ; double premod_score = 0 ; int headIndex = node -> getHeadIndex ( ) ; for ( int j = 0 ; j < headIndex ; j ++ ) { premodVector [ 2 ] = premodBackoffVector [ 1 ] = node -> getChild ( j ) -> getHeadWord ( ) ; double frontProb = exp ( _modModel -> getProbability ( premodVector ) ) ; double frontLambda = _modModel -> getIncorrectLambda ( premodVector ) ; double backProb = exp ( _modBackoffModel -> getProbability ( premodBackoffVector ) ) ; double backLambda = _modBackoffModel -> getIncorrectLambda ( premodBackoffVector ) ; double combined_score = ( frontLambda * frontProb ) + ( ( 1.0 - frontLambda ) * ( ( backLambda * backProb ) + ( ( 1.0 - backLambda ) * 1.0 / _VOCAB_SIZE ) ) ) ; premod_score += combined_score == 0 ? _LOG_OF_ZERO : log ( combined_score ) ; } return premod_score ; }
Calculate the PreModifier portion of the Descriptor Classifier Score
Calculate the PreModifier portion of the Descriptor Classifier Score
// Modifier  is (type, stemmed_head, mod_head)
 // mod backoff is (type, mod_head)
 // WARNING: the incorrect lambda is being used for comparison to old system
 // WARNING: the incorrect lambda is being used for comparison to old system
