src/Generic/theories/MentionConfidence.cpp
/* This is a modified version to return the name mention portion of the mention if there is one */
This is a modified version to return the name mention portion of the mention if there is one
This is a modified version to return the name mention portion of the mention if there is one
const Mention* MentionConfidence::nameFromTitleDescriptor(const Mention* desc_mention, const Entity *ent, const MentionSet* mentionSet)
{
	if (desc_mention->getMentionType() != Mention::DESC){
		return 0;
	}
	const Mention* parentMention = 0;
	const SynNode *dnode = desc_mention->getNode();
	if (!enIsNominalPremod(dnode))	
		return 0;
	while(dnode->getParent()){
		if (dnode->getParent()->hasMention() && 
			mentionSet->getMention(dnode->getParent()->getMentionIndex())->getMentionType() == Mention::NAME){
			parentMention =  mentionSet->getMention(dnode->getParent()->getMentionIndex());
			break;
		}
		else{
			dnode = dnode->getParent();
		}
	}
	if (parentMention == 0)
		return 0;
	if (!ent->containsMention(parentMention))
		return 0;
	if (parentMention->getMentionType() != Mention::NAME)
		return 0;
	const SynNode *node = parentMention->node;
	const SynNode *NPPnode = parentMention->node->getHeadPreterm()->getParent();
	if (node == NPPnode)
		return 0;
	node = NPPnode->getParent();
	if (node == 0)
		return 0;
	int nkids = node->getNChildren();
	if (nkids < 2)
		return 0;
	for (int j = 0; j < node->getNChildren(); j++) {
		const SynNode *child = node->getChild(j);
		if (child->getTag() == EN_CC || child->getTag() == EN_COMMA) {
			return 0;
		}
	}
	const SynNode *child = node->getChild(nkids-1);
	if (!child->hasMention())
		return 0;
	const Mention *rightmost_ment = mentionSet->getMentionByNode(child);
	if (rightmost_ment->getMentionType() == Mention::NAME) {
	}
	else if (rightmost_ment->getMentionType() == Mention::NONE) {
		if (rightmost_ment->getParent() != parentMention)
			return 0;
	}
	else {
		return 0;
	}
	if (!rightmost_ment->isOfRecognizedType())
		return 0;
	child = node->getChild(nkids-2);
	if (!child->hasMention() || !enIsNominalPremod(child))
		return 0;
	const Mention *next_ment = mentionSet->getMentionByNode(child);
	if (next_ment->getMentionType() != Mention::DESC)
	{
		return 0;
	}
	if(next_ment->getUID() == desc_mention->getUID()){
		return rightmost_ment;
	}
	else{
		return 0;
	}	
}
const Mention * MentionConfidence :: nameFromTitleDescriptor ( const Mention * desc_mention , const Entity * ent , const MentionSet * mentionSet ) { if ( desc_mention -> getMentionType ( ) != Mention :: DESC ) { return 0 ; } const Mention * parentMention = 0 ; const SynNode * dnode = desc_mention -> getNode ( ) ; if ( ! enIsNominalPremod ( dnode ) ) return 0 ; while ( dnode -> getParent ( ) ) { if ( dnode -> getParent ( ) -> hasMention ( ) && mentionSet -> getMention ( dnode -> getParent ( ) -> getMentionIndex ( ) ) -> getMentionType ( ) == Mention :: NAME ) { parentMention = mentionSet -> getMention ( dnode -> getParent ( ) -> getMentionIndex ( ) ) ; break ; } else { dnode = dnode -> getParent ( ) ; } } if ( parentMention == 0 ) return 0 ; if ( ! ent -> containsMention ( parentMention ) ) return 0 ; if ( parentMention -> getMentionType ( ) != Mention :: NAME ) return 0 ; const SynNode * node = parentMention -> node ; const SynNode * NPPnode = parentMention -> node -> getHeadPreterm ( ) -> getParent ( ) ; if ( node == NPPnode ) return 0 ; node = NPPnode -> getParent ( ) ; if ( node == 0 ) return 0 ; int nkids = node -> getNChildren ( ) ; if ( nkids < 2 ) return 0 ; for ( int j = 0 ; j < node -> getNChildren ( ) ; j ++ ) { const SynNode * child = node -> getChild ( j ) ; if ( child -> getTag ( ) == EN_CC || child -> getTag ( ) == EN_COMMA ) { return 0 ; } } const SynNode * child = node -> getChild ( nkids - 1 ) ; if ( ! child -> hasMention ( ) ) return 0 ; const Mention * rightmost_ment = mentionSet -> getMentionByNode ( child ) ; if ( rightmost_ment -> getMentionType ( ) == Mention :: NAME ) { } else if ( rightmost_ment -> getMentionType ( ) == Mention :: NONE ) { if ( rightmost_ment -> getParent ( ) != parentMention ) return 0 ; } else { return 0 ; } if ( ! rightmost_ment -> isOfRecognizedType ( ) ) return 0 ; child = node -> getChild ( nkids - 2 ) ; if ( ! child -> hasMention ( ) || ! enIsNominalPremod ( child ) ) return 0 ; const Mention * next_ment = mentionSet -> getMentionByNode ( child ) ; if ( next_ment -> getMentionType ( ) != Mention :: DESC ) { return 0 ; } if ( next_ment -> getUID ( ) == desc_mention -> getUID ( ) ) { return rightmost_ment ; } else { return 0 ; } }
This is a modified version to return the name mention portion of the mention if there is one
This is a modified version to return the name mention portion of the mention if there is one
//find the immediately following name 
 //must be nominal premod descriptor
 // node must have at least two children
 // no commas or CCs allowed
 // rightmost child must be a name mention
 // keep it
 // make sure this is the name child
 // who knows what kind of mention *this* is
 // second-next-rightmost child must be a nominal premod descriptor
 // make sure that the descriptor mention and the name mention link to the same entity
 // I doubt this  -- try the right-msot-mention instead
 // return next_ment;
