src/Generic/theories/MentionConfidence.cpp
/* returns the mention that is a name if there is one that meets all criteria  */
returns the mention that is a name if there is one that meets all criteria
returns the mention that is a name if there is one that meets all criteria
const Mention* MentionConfidence::nameFromCopulaDescriptor(const Mention* ment, const Entity* ent, const PropositionSet* prop_set, const MentionSet* mentionSet)
{
	if(ment->getMentionType() != Mention::DESC){
		return 0;
	}
	std::vector<Proposition*> copulas;
	for(int p_no = 0; p_no < prop_set->getNPropositions(); p_no++){
		if(prop_set->getProposition(p_no)->getPredType() == Proposition::COPULA_PRED){
			copulas.push_back(prop_set->getProposition(p_no));
		}
	}
	if(copulas.size() == 0){
		return 0;
	}
	for(std::vector<Proposition*>::iterator iter = copulas.begin(); iter != copulas.end(); iter++){
		Proposition* prop = (*iter);
		if(prop->getArg(0)->getType() != Argument::MENTION_ARG || prop->getArg(1)->getType() != Argument::MENTION_ARG){
			continue;
		}
		const Mention *lhs = prop->getArg(0)->getMention(mentionSet);
		const Mention *rhs = prop->getArg(1)->getMention(mentionSet);
		if(!lhs || !rhs){
			std::ostringstream ostr;
			ostr<<"MentionConfidence::isCopulaDescriptor(), no lhs/rhs: ";
			ment->dump(ostr);
			prop->dump(ostr);
			ostr<<std::endl;
			ent->dump(ostr);
			ostr<<std::endl;
			SessionLogger::dbg("mention_confidence") << ostr.str();
		}
		else if(lhs->getUID() == ment->getUID()){
			if((rhs->getMentionType() == Mention::NAME) 
				&& (ent->containsMention(rhs)))
			{
				return rhs;
			}
		}
		else if(rhs->getUID() == ment->getUID()) {
			if((lhs->getMentionType() == Mention::NAME)
				&& (ent->containsMention(lhs)))
			{
				return lhs;
			}
		}
	}
	return 0;
}
const Mention * MentionConfidence :: nameFromCopulaDescriptor ( const Mention * ment , const Entity * ent , const PropositionSet * prop_set , const MentionSet * mentionSet ) { if ( ment -> getMentionType ( ) != Mention :: DESC ) { return 0 ; } std :: vector < Proposition * > copulas ; for ( int p_no = 0 ; p_no < prop_set -> getNPropositions ( ) ; p_no ++ ) { if ( prop_set -> getProposition ( p_no ) -> getPredType ( ) == Proposition :: COPULA_PRED ) { copulas . push_back ( prop_set -> getProposition ( p_no ) ) ; } } if ( copulas . size ( ) == 0 ) { return 0 ; } for ( std :: vector < Proposition * > :: iterator iter = copulas . begin ( ) ; iter != copulas . end ( ) ; iter ++ ) { Proposition * prop = ( * iter ) ; if ( prop -> getArg ( 0 ) -> getType ( ) != Argument :: MENTION_ARG || prop -> getArg ( 1 ) -> getType ( ) != Argument :: MENTION_ARG ) { continue ; } const Mention * lhs = prop -> getArg ( 0 ) -> getMention ( mentionSet ) ; const Mention * rhs = prop -> getArg ( 1 ) -> getMention ( mentionSet ) ; if ( ! lhs || ! rhs ) { std :: ostringstream ostr ; ostr << " " ; ment -> dump ( ostr ) ; prop -> dump ( ostr ) ; ostr << std :: endl ; ent -> dump ( ostr ) ; ostr << std :: endl ; SessionLogger :: dbg ( " " ) << ostr . str ( ) ; } else if ( lhs -> getUID ( ) == ment -> getUID ( ) ) { if ( ( rhs -> getMentionType ( ) == Mention :: NAME ) && ( ent -> containsMention ( rhs ) ) ) { return rhs ; } } else if ( rhs -> getUID ( ) == ment -> getUID ( ) ) { if ( ( lhs -> getMentionType ( ) == Mention :: NAME ) && ( ent -> containsMention ( lhs ) ) ) { return lhs ; } } } return 0 ; }
returns the mention that is a name if there is one that meets all criteria
returns the mention that is a name if there is one that meets all criteria