src/PredFinder/common/ElfMultiDoc.cpp
/** 
 * Finds the XDoc ID that is used most often and/or corresponds to the longest word sequence.
 **/
Finds the XDoc ID that is used most often and/or corresponds to the longest word sequence.
Finds the XDoc ID that is used most often and / or corresponds to the longest word sequence .
XDocIdType ElfMultiDoc::get_best_potential_xdoc_id(const Entity* entity, 
												   const PotentialXdocIdToCountAndGreatestLengthMap & potential_ids, 
												   const XDocIdType & best_xdoc_id_so_far) {
	XDocIdType best_uri(best_xdoc_id_so_far);														 														 
	int max_count = 0;
	int max_count_size = 0;
	int longest_size = 0;
	int longest_count = 0;
	XDocIdType freq_uri, longest_uri;
	if (potential_ids.size() > 0) {
		BOOST_FOREACH(PotentialXdocIdToCountAndGreatestLengthMap::value_type potential_id, potential_ids){
			SessionLogger::info("potential_id_first") << "potential_id.first: <" << potential_id.first << ">" << std::endl;
			if (max_count <= potential_id.second.first) {
				max_count = potential_id.second.first;
				max_count_size = potential_id.second.second;
				freq_uri = potential_id.first;
			}
			if (longest_size <= potential_id.second.second) {
				longest_count = potential_id.second.first;
				longest_size = potential_id.second.second;
				longest_uri = potential_id.first;
			}
		}
		if (entity->getType().matchesPER()){
			if(max_count_size == longest_size){
				best_uri = freq_uri;
			} else {
				best_uri = longest_uri;
			}
		}
		else{
			if (longest_count >= max_count + 2) {
				best_uri = longest_uri;
			} else {
				best_uri = freq_uri; 
			}
		}
	}
	return best_uri;
}
XDocIdType ElfMultiDoc :: get_best_potential_xdoc_id ( const Entity * entity , const PotentialXdocIdToCountAndGreatestLengthMap & potential_ids , const XDocIdType & best_xdoc_id_so_far ) { XDocIdType best_uri ( best_xdoc_id_so_far ) ; int max_count = 0 ; int max_count_size = 0 ; int longest_size = 0 ; int longest_count = 0 ; XDocIdType freq_uri , longest_uri ; if ( potential_ids . size ( ) > 0 ) { BOOST_FOREACH ( PotentialXdocIdToCountAndGreatestLengthMap :: value_type potential_id , potential_ids ) { SessionLogger :: info ( " " ) << " " << potential_id . first << " " << std :: endl ; if ( max_count <= potential_id . second . first ) { max_count = potential_id . second . first ; max_count_size = potential_id . second . second ; freq_uri = potential_id . first ; } if ( longest_size <= potential_id . second . second ) { longest_count = potential_id . second . first ; longest_size = potential_id . second . second ; longest_uri = potential_id . first ; } } if ( entity -> getType ( ) . matchesPER ( ) ) { if ( max_count_size == longest_size ) { best_uri = freq_uri ; } else { best_uri = longest_uri ; } } else { if ( longest_count >= max_count + 2 ) { best_uri = longest_uri ; } else { best_uri = freq_uri ; } } } return best_uri ; }
Finds the XDoc ID that is used most often and/or corresponds to the longest word sequence.
Finds the XDoc ID that is used most often and / or corresponds to the longest word sequence .
// Determine which URI found from coreferent mentions we should use
 // Find the potential ID mappings with the highest count and longest URI
 // This code is not hit for the first batch of IC or NFL dry run.
 // Simple heuristic: if longest_count is within 2 of frequency of max_count, use longest_size; otherwise, use max_count.
 //                   For entities of type PER,  use the longest name (since shorter names are likely to be ambiguous)
 //For people, avoid one word names
 // Done; could still be invalid
