src/Generic/edt/discmodel/CorefUtils.cpp
/**
 *  Given an array of EntityGuess objects with scores, compute
 *  the confidence for each score and set the corresponding
 *  <code>linkConfidence</code> field for each EntityGuess
 * 
 *  @param results the array of EntityGuess object
 *  @param nResults the length of the array
 */
Given an array of EntityGuess objects with scores, compute
the confidence for each score and set the corresponding
linkConfidence field for each EntityGuess

@param results the array of EntityGuess object
@param nResults the length of the array
Given an array of EntityGuess objects with scores compute the confidence for each score and set the corresponding linkConfidence field for each EntityGuess @param results the array of EntityGuess object @param nResults the length of the array
void CorefUtils::computeConfidence(EntityGuess results[], int nResults) {
	if (nResults < 3) { 
		for (int i = 0; i < nResults; i++) {
			results[i].linkConfidence = static_cast<float>(1.0);
		}
		return;
	}
	float normalizer = static_cast<float>(((fabs(results[2].score))+ fabs(results[1].score))/2);
	if (normalizer <=0.0) return; 
	float sec_best_conf = static_cast<float>(results[1].score/normalizer);
	float best_conf = static_cast<float>(results[0].score/normalizer-sec_best_conf);
	float divider = (best_conf > 600) ? best_conf/600 : 1;
	float sum_of_confs = 0.0;
	for (int i = 0; i < nResults; i++) {
		results[i].linkConfidence = static_cast<float>(results[i].score/normalizer);
		results[i].linkConfidence -= sec_best_conf;
		results[i].linkConfidence /= divider;
		results[i].linkConfidence = exp(results[i].linkConfidence);
		sum_of_confs += results[i].linkConfidence;
	}
	for (int i = 0; i < nResults; i++) {
		results[i].linkConfidence /= sum_of_confs;
		if (boost::math::isnan(results[i].linkConfidence))
			results[i].linkConfidence = static_cast<float>(1.0);
	}
}
void CorefUtils :: computeConfidence ( EntityGuess results [ ] , int nResults ) { if ( nResults < 3 ) { for ( int i = 0 ; i < nResults ; i ++ ) { results [ i ] . linkConfidence = static_cast < float > ( 1.0 ) ; } return ; } float normalizer = static_cast < float > ( ( ( fabs ( results [ 2 ] . score ) ) + fabs ( results [ 1 ] . score ) ) / 2 ) ; if ( normalizer <= 0.0 ) return ; float sec_best_conf = static_cast < float > ( results [ 1 ] . score / normalizer ) ; float best_conf = static_cast < float > ( results [ 0 ] . score / normalizer - sec_best_conf ) ; float divider = ( best_conf > 600 ) ? best_conf / 600 : 1 ; float sum_of_confs = 0.0 ; for ( int i = 0 ; i < nResults ; i ++ ) { results [ i ] . linkConfidence = static_cast < float > ( results [ i ] . score / normalizer ) ; results [ i ] . linkConfidence -= sec_best_conf ; results [ i ] . linkConfidence /= divider ; results [ i ] . linkConfidence = exp ( results [ i ] . linkConfidence ) ; sum_of_confs += results [ i ] . linkConfidence ; } for ( int i = 0 ; i < nResults ; i ++ ) { results [ i ] . linkConfidence /= sum_of_confs ; if ( boost :: math :: isnan ( results [ i ] . linkConfidence ) ) results [ i ] . linkConfidence = static_cast < float > ( 1.0 ) ; } }
Given an array of EntityGuess objects with scores, compute
  the confidence for each score and set the corresponding
  <code>linkConfidence</code> field for each EntityGuess
Given an array of EntityGuess objects with scores compute the confidence for each score and set the corresponding <code > linkConfidence< / code > field for each EntityGuess
// set confidence to maximum
 // to make sure we are not dividing by 0;
 // this is to prevent overflow in the exponent
 // normalizing the scores
 // normalizing the scores
 // just set it to 1.0 for now if we're getting NaN
