src/English/metonymy/en_MetonymyAdder.cpp
/*
 * Bonan: cherrypick code for resolving metony for TAC; dealing with GPE-ORG/sportsTeam and ORG-FAC metonymy
 */
cherrypick code for resolving metony for TAC; dealing with GPE-ORG/sportsTeam and ORG-FAC metonymy
cherrypick code for resolving metony for TAC ; dealing with GPE - ORG / sportsTeam and ORG - FAC metonymy
void EnglishMetonymyAdder::resolveMetonymyForTAC(const MentionSet *mentionSet,
											 const PropositionSet *propSet) {
 	for (int i = 0; i < propSet->getNPropositions(); i++) {
		Proposition *prop = propSet->getProposition(i);
		if (prop->getPredType() == Proposition::NOUN_PRED ||
			prop->getPredType() == Proposition::NAME_PRED) {
			const Mention *ref = prop->getMentionOfRole(Argument::REF_ROLE, mentionSet);
			for (int j = 0; j < prop->getNArgs(); j++) {
				Argument *arg = prop->getArg(j);
				if (arg->getType() == Argument::MENTION_ARG) {
					Mention *ment = mentionSet->getMention(arg->getMentionIndex());
					if (ment->getEntityType().matchesGPE()) {
						if (ment == 0 || !ment->getEntityType().matchesGPE())
							continue;
						if (arg->getRoleSym() == Argument::POSS_ROLE) {
							if (_is_sports_story && ment->mentionType == Mention::NAME) {
								if (!ref->getEntityType().matchesORG()) {
									_debug << "Mention: " << ment->getUID() << "\n" << ment->getNode()->toPrettyParse(2);
									_debug << "\n possessive GPE in sports story -> sports metonymy\n";
									changeGPEintoSportsTeam(ment); 
								}
							}
						}
						else if (arg->getRoleSym() == Argument::REF_ROLE) {
							if (isSportsTeam(ment)) 
								continue;
						}
					}
					else if (ment->getEntityType().matchesORG()) {
						if (ment == 0 || !ment->getEntityType().matchesORG())
							continue;
						if (arg->getRoleSym() == Argument::REF_ROLE && isOrgFacSpecialCase(ment)) {
							_debug << "Mention: " << ment->getUID() << "\n" << ment->getNode()->toPrettyParse(2);
							_debug << "\n ORG as FAC special case\n";
							changeTypeORGintoFAC(ment);
						}
					}
					else if (ment->getEntityType().matchesFAC()) {
						if (ment == 0 || !ment->getEntityType().matchesFAC())
							continue;
						if (arg->getRoleSym() == Argument::REF_ROLE && isFacOrgSpecialCase(ment)) {
							_debug << "Mention: " << ment->getUID() << "\n" << ment->getNode()->toPrettyParse(2);
							_debug << "\n FAC as ORG special case\n";
							changeTypeFACintoORG(ment);
						}
					}
				}
			}
		}
		else if (prop->getPredType() == Proposition::VERB_PRED || prop->getPredType() == Proposition::COPULA_PRED) {
			const SynNode *verbNode = prop->getPredHead();
			for (int j = 0; j < prop->getNArgs(); j++) {
				Argument *arg = prop->getArg(j);
				if (arg->getType() == Argument::MENTION_ARG) {
					Mention *ment = mentionSet->getMention(arg->getMentionIndex());
					if (ment->getEntityType().matchesGPE()) {
						const Symbol verb = verbNode->getHeadWord();
						if (ment == 0 || !ment->getEntityType().matchesGPE())
							continue;
						if (arg->getRoleSym() == Argument::SUB_ROLE) {
							if (_is_sports_story && ment->getMentionType() == Mention::NAME) {
								_debug << "Mention: " << ment->getUID() << "\n" << ment->getNode()->toPrettyParse(2);
								_debug << "\n GPE SUBJ in sports story -> sports metonymy\n";
								changeGPEintoSportsTeam(ment); 
							}
						}
					}	
					else if (ment->getEntityType().matchesFAC()) {
						const Symbol verb = verbNode->getHeadWord();
						if (ment == 0 || !ment->getEntityType().matchesFAC())
							continue;
						if (arg->getRoleSym() == Argument::OBJ_ROLE || arg->getRoleSym() == Argument::SUB_ROLE) {
							if (_functioningAsOrgVerbs->lookup(verb)) {
								_debug << "Mention: " << ment->getUID() << "\n" << ment->getNode()->toPrettyParse(2);
								_debug << "\n functioning_as_org_verb FAC -> FAC.ORG\n";
								addMetonymyToMention(ment, EntityType::getORGType());
							}
						}
						else if (arg->getRoleSym() == sym_with || arg->getRoleSym() == sym_against) {
							_debug << "Mention: " << ment->getUID() << "\n" << ment->getNode()->toPrettyParse(2);
							_debug << "\n verb with/against FAC -> FAC.ORG\n";
							changeTypeFACintoORG(ment);
						}
					}
					else if (ment->getEntityType().matchesORG()) {
						Mention *ment = mentionSet->getMention(arg->getMentionIndex());
						const Symbol verb = verbNode->getHeadWord();
						if (ment == 0 || !ment->getEntityType().matchesORG())
							continue;
						if (arg->getRoleSym() == Argument::OBJ_ROLE) {
							if (_functioningAsFacVerbs->lookup(verb)) {
								_debug << "Mention: " << ment->getUID() << "\n" << ment->getNode()->toPrettyParse(2);
								_debug << "\n functioning_as_fac_verb ORG -> ORG.FAC\n";
								changeTypeORGintoFAC(ment);
							}
						}
					}
				}
			}
		}
	}
}
void EnglishMetonymyAdder :: resolveMetonymyForTAC ( const MentionSet * mentionSet , const PropositionSet * propSet ) { for ( int i = 0 ; i < propSet -> getNPropositions ( ) ; i ++ ) { Proposition * prop = propSet -> getProposition ( i ) ; if ( prop -> getPredType ( ) == Proposition :: NOUN_PRED || prop -> getPredType ( ) == Proposition :: NAME_PRED ) { const Mention * ref = prop -> getMentionOfRole ( Argument :: REF_ROLE , mentionSet ) ; for ( int j = 0 ; j < prop -> getNArgs ( ) ; j ++ ) { Argument * arg = prop -> getArg ( j ) ; if ( arg -> getType ( ) == Argument :: MENTION_ARG ) { Mention * ment = mentionSet -> getMention ( arg -> getMentionIndex ( ) ) ; if ( ment -> getEntityType ( ) . matchesGPE ( ) ) { if ( ment == 0 || ! ment -> getEntityType ( ) . matchesGPE ( ) ) continue ; if ( arg -> getRoleSym ( ) == Argument :: POSS_ROLE ) { if ( _is_sports_story && ment -> mentionType == Mention :: NAME ) { if ( ! ref -> getEntityType ( ) . matchesORG ( ) ) { _debug << " " << ment -> getUID ( ) << " \n " << ment -> getNode ( ) -> toPrettyParse ( 2 ) ; _debug << " \n \n " ; changeGPEintoSportsTeam ( ment ) ; } } } else if ( arg -> getRoleSym ( ) == Argument :: REF_ROLE ) { if ( isSportsTeam ( ment ) ) continue ; } } else if ( ment -> getEntityType ( ) . matchesORG ( ) ) { if ( ment == 0 || ! ment -> getEntityType ( ) . matchesORG ( ) ) continue ; if ( arg -> getRoleSym ( ) == Argument :: REF_ROLE && isOrgFacSpecialCase ( ment ) ) { _debug << " " << ment -> getUID ( ) << " \n " << ment -> getNode ( ) -> toPrettyParse ( 2 ) ; _debug << " \n \n " ; changeTypeORGintoFAC ( ment ) ; } } else if ( ment -> getEntityType ( ) . matchesFAC ( ) ) { if ( ment == 0 || ! ment -> getEntityType ( ) . matchesFAC ( ) ) continue ; if ( arg -> getRoleSym ( ) == Argument :: REF_ROLE && isFacOrgSpecialCase ( ment ) ) { _debug << " " << ment -> getUID ( ) << " \n " << ment -> getNode ( ) -> toPrettyParse ( 2 ) ; _debug << " \n \n " ; changeTypeFACintoORG ( ment ) ; } } } } } else if ( prop -> getPredType ( ) == Proposition :: VERB_PRED || prop -> getPredType ( ) == Proposition :: COPULA_PRED ) { const SynNode * verbNode = prop -> getPredHead ( ) ; for ( int j = 0 ; j < prop -> getNArgs ( ) ; j ++ ) { Argument * arg = prop -> getArg ( j ) ; if ( arg -> getType ( ) == Argument :: MENTION_ARG ) { Mention * ment = mentionSet -> getMention ( arg -> getMentionIndex ( ) ) ; if ( ment -> getEntityType ( ) . matchesGPE ( ) ) { const Symbol verb = verbNode -> getHeadWord ( ) ; if ( ment == 0 || ! ment -> getEntityType ( ) . matchesGPE ( ) ) continue ; if ( arg -> getRoleSym ( ) == Argument :: SUB_ROLE ) { if ( _is_sports_story && ment -> getMentionType ( ) == Mention :: NAME ) { _debug << " " << ment -> getUID ( ) << " \n " << ment -> getNode ( ) -> toPrettyParse ( 2 ) ; _debug << " \n \n " ; changeGPEintoSportsTeam ( ment ) ; } } } else if ( ment -> getEntityType ( ) . matchesFAC ( ) ) { const Symbol verb = verbNode -> getHeadWord ( ) ; if ( ment == 0 || ! ment -> getEntityType ( ) . matchesFAC ( ) ) continue ; if ( arg -> getRoleSym ( ) == Argument :: OBJ_ROLE || arg -> getRoleSym ( ) == Argument :: SUB_ROLE ) { if ( _functioningAsOrgVerbs -> lookup ( verb ) ) { _debug << " " << ment -> getUID ( ) << " \n " << ment -> getNode ( ) -> toPrettyParse ( 2 ) ; _debug << " \n \n " ; addMetonymyToMention ( ment , EntityType :: getORGType ( ) ) ; } } else if ( arg -> getRoleSym ( ) == sym_with || arg -> getRoleSym ( ) == sym_against ) { _debug << " " << ment -> getUID ( ) << " \n " << ment -> getNode ( ) -> toPrettyParse ( 2 ) ; _debug << " \n \n " ; changeTypeFACintoORG ( ment ) ; } } else if ( ment -> getEntityType ( ) . matchesORG ( ) ) { Mention * ment = mentionSet -> getMention ( arg -> getMentionIndex ( ) ) ; const Symbol verb = verbNode -> getHeadWord ( ) ; if ( ment == 0 || ! ment -> getEntityType ( ) . matchesORG ( ) ) continue ; if ( arg -> getRoleSym ( ) == Argument :: OBJ_ROLE ) { if ( _functioningAsFacVerbs -> lookup ( verb ) ) { _debug << " " << ment -> getUID ( ) << " \n " << ment -> getNode ( ) -> toPrettyParse ( 2 ) ; _debug << " \n \n " ; changeTypeORGintoFAC ( ment ) ; } } } } } } } }
Bonan: cherrypick code for resolving metony for TAC; dealing with GPE-ORG/sportsTeam and ORG-FAC metonymy
Bonan : cherrypick code for resolving metony for TAC ; dealing with GPE - ORG / sportsTeam and ORG - FAC metonymy
// GPE
 // Boston's struggling bullpen
 // Bonan: this should be kept
 // Bonan: should be kept									
 // ORG
 // addMetonymyToMention(ment, EntityType::getFACType());
 // FAC
 // addMetonymyToMention(ment, EntityType::getORGType());
 // GPE
 // *Boston* celebrated in their dugout after beating New York
 // Bonan: This should be kept
 // FAC
 // EMB: This was wrong as of 9/15, should be looking at ORGs here to see if they are
 //   acting like FACs
 // JSM:  I think this is backwards.  According to the calling function it should be
 //   looking for FACs.  1/05/07
 // addMetonymyToMention(ment, EntityType::getORGType());
 // ORG
 // EMB: This was wrong as of 9/15, should be looking at FACs here to see if they are
 //   acting like ORGs
 // JSM:  I think this is backwards.  According to the calling function it should be
 //   looking for ORGs.  1/05/07
 // addMetonymyToMention(ment, EntityType::getFACType());
