src/LearnIt/BestName.cpp
// Get a best name from the mention. Use its head if it has one and full text 
//    is not requested, otherwise use full text.
//	Give it a confidence based on the mention type.

Get a best name from the mention. Use its head if it has one and full text
is not requested, otherwise use full text.
Give it a confidence based on the mention type.
Get a best name from the mention . Use its head if it has one and full text is not requested otherwise use full text . Give it a confidence based on the mention type .
BestName BestName::_findBestMentionName(const Mention* mention,
	const SentenceTheory* st, bool fullText, bool prefer_better_coref_name)
{
	const SynNode* mention_head = mention->getHead();
	Mention::Type mention_type = mention->getMentionType();
	EDTOffset start_offset = st->getTokenSequence()->
		getToken(mention->getNode()->getStartToken())->getStartEDTOffset();
	EDTOffset end_offset = st->getTokenSequence()->
		getToken(mention->getNode()->getEndToken())->getEndEDTOffset();
	double confidence=0.0;
	switch(mention_type) {
		case Mention::NAME: 
			if (mention_head) {
				start_offset = st->getTokenSequence()->getToken(
					mention_head->getStartToken())->getStartEDTOffset();
				end_offset = st->getTokenSequence()->getToken(
					mention_head->getEndToken())->getEndEDTOffset();
			}
			if (prefer_better_coref_name) {
				confidence = 0.9999;
			} else {
				confidence = 1.0;
			}
			break;
		case Mention::APPO: 
			if (mention_head && mention_head->hasMention()) {
				const MentionSet* mention_set = st->getMentionSet();
				Mention *m = mention_set->getMention(mention_head->getMentionIndex());
				mention_type = m->getMentionType();
				start_offset = st->getTokenSequence()->getToken(
					mention_head->getStartToken())->getStartEDTOffset();
				end_offset = st->getTokenSequence()->getToken(
					mention_head->getEndToken())->getEndEDTOffset();
				if (m->getMentionType() == Mention::NAME)
					confidence = 1.0;
				else
					confidence = 0.5;
			}
			break;
		case Mention::DESC: 
			confidence = 0.4; break;
		case Mention::LIST: 
			confidence = 0.2; break;
		case Mention::PRON: 
			confidence = 0.0; break; 
		case Mention::PART: 
			confidence = 0.0; break;
		case Mention::INFL: 
			confidence = 0.0; break;
		default:
			confidence = 0.0; break;
	}
	wstring bestNameString=L"";
	if (mention_head && !fullText) {
		bestNameString = (mention_head->toCasedTextString(st->getTokenSequence()));
	} else {
		bestNameString = mention->getNode()->toCasedTextString(st->getTokenSequence());;
	}
	return BestName(bestNameString, confidence, mention_type, 
		start_offset, end_offset);
}
BestName BestName :: _findBestMentionName ( const Mention * mention , const SentenceTheory * st , bool fullText , bool prefer_better_coref_name ) { const SynNode * mention_head = mention -> getHead ( ) ; Mention :: Type mention_type = mention -> getMentionType ( ) ; EDTOffset start_offset = st -> getTokenSequence ( ) -> getToken ( mention -> getNode ( ) -> getStartToken ( ) ) -> getStartEDTOffset ( ) ; EDTOffset end_offset = st -> getTokenSequence ( ) -> getToken ( mention -> getNode ( ) -> getEndToken ( ) ) -> getEndEDTOffset ( ) ; double confidence = 0.0 ; switch ( mention_type ) { case Mention :: NAME : if ( mention_head ) { start_offset = st -> getTokenSequence ( ) -> getToken ( mention_head -> getStartToken ( ) ) -> getStartEDTOffset ( ) ; end_offset = st -> getTokenSequence ( ) -> getToken ( mention_head -> getEndToken ( ) ) -> getEndEDTOffset ( ) ; } if ( prefer_better_coref_name ) { confidence = 0.9999 ; } else { confidence = 1.0 ; } break ; case Mention :: APPO : if ( mention_head && mention_head -> hasMention ( ) ) { const MentionSet * mention_set = st -> getMentionSet ( ) ; Mention * m = mention_set -> getMention ( mention_head -> getMentionIndex ( ) ) ; mention_type = m -> getMentionType ( ) ; start_offset = st -> getTokenSequence ( ) -> getToken ( mention_head -> getStartToken ( ) ) -> getStartEDTOffset ( ) ; end_offset = st -> getTokenSequence ( ) -> getToken ( mention_head -> getEndToken ( ) ) -> getEndEDTOffset ( ) ; if ( m -> getMentionType ( ) == Mention :: NAME ) confidence = 1.0 ; else confidence = 0.5 ; } break ; case Mention :: DESC : confidence = 0.4 ; break ; case Mention :: LIST : confidence = 0.2 ; break ; case Mention :: PRON : confidence = 0.0 ; break ; case Mention :: PART : confidence = 0.0 ; break ; case Mention :: INFL : confidence = 0.0 ; break ; default : confidence = 0.0 ; break ; } wstring bestNameString = L" " ; if ( mention_head && ! fullText ) { bestNameString = ( mention_head -> toCasedTextString ( st -> getTokenSequence ( ) ) ) ; } else { bestNameString = mention -> getNode ( ) -> toCasedTextString ( st -> getTokenSequence ( ) ) ; ; } return BestName ( bestNameString , confidence , mention_type , start_offset , end_offset ) ; }
Get a best name from the mention.
Get a best name from the mention .
// E.g.: John
 // E.g.: President John
 // E.g.: John, the baker
 // E.g.: the baker
 // E.g.: (??)
 // E.g.: he
 // A pronoun w/ no referent is not useful!
 // E.g.: ??
 // E.g.: ??
