src/PredFinder/inference/EIUtils.cpp
/**
 * Call ElfMultiDoc::merge_entities_in_map() on the named entity for the given mention (which we know refers to a person) in the given sentence,
 * given that the following criteria are met:
 * - entity is described in an event mention in this sentence as a victim
 * - entity is named
 * - sentence has only one name mention
 **/
Call ElfMultiDoc::merge_entities_in_map() on the named entity for the given mention (which we know refers to a person) in the given sentence,
given that the following criteria are met:
- entity is described in an event mention in this sentence as a victim
- entity is named
- sentence has only one name mention
Call ElfMultiDoc :: merge_entities_in_map () on the named entity for the given mention ( which we know refers to a person ) in the given sentence given that the following criteria are met : - entity is described in an event mention in this sentence as a victim - entity is named - sentence has only one name mention
void EIUtils::attemptNewswireLeadFix(const DocTheory *docTheory, int sent_no, const Mention *potentialDescMention) {
	if (sent_no == docTheory->getNSentences() - 1)
		return;
	const EntitySet* ents = docTheory->getEntitySet();
	SentenceTheory *st = docTheory->getSentenceTheory(sent_no);
	EventMentionSet *ems = st->getEventMentionSet();
	bool is_victim = false;
	for (int e = 0; e < ems->getNEventMentions(); e++) {
		const EventMention *em = ems->getEventMention(e);
		for (int a = 0; a < em->getNArgs(); a++) {
			if (em->getNthArgRole(a) == Symbol(L"Victim") &&
				em->getNthArgMention(a) == potentialDescMention)
			{
				is_victim = true;
				break;
			}
		}
	}
	if (!is_victim)
		return;
	Entity *potentialDescEnt = ents->getEntityByMention(potentialDescMention->getUID());	
	for (int m = 0; m < potentialDescEnt->getNMentions(); m++) {
		if (ents->getMention(potentialDescEnt->getMention(m))->getMentionType() == Mention::NAME) {
			return;
		}
	}
	SentenceTheory *nextSentence = docTheory->getSentenceTheory(sent_no + 1);
	const MentionSet *nextMS = nextSentence->getMentionSet();
	const Mention *nameMention = 0;
	for (int m = 0; m < nextMS->getNMentions(); m++) {
		if (nextMS->getMention(m)->getMentionType() == Mention::NAME)
		{
			if (nextMS->getMention(m)->getEntityType() == potentialDescMention->getEntityType()) {
				if (nameMention != 0)
					return;
				else nameMention = nextMS->getMention(m);
			}
		}
	}
	if (nameMention == 0)
		return;
	Entity *nameEnt = ents->getEntityByMention(nameMention->getUID());
	if (nameEnt == 0)
		return;
	std::set<int> descIDSet;
	descIDSet.insert(potentialDescEnt->getID());
	ElfMultiDoc::merge_entities_in_map(docTheory, nameEnt->getID(), descIDSet);
}
void EIUtils :: attemptNewswireLeadFix ( const DocTheory * docTheory , int sent_no , const Mention * potentialDescMention ) { if ( sent_no == docTheory -> getNSentences ( ) - 1 ) return ; const EntitySet * ents = docTheory -> getEntitySet ( ) ; SentenceTheory * st = docTheory -> getSentenceTheory ( sent_no ) ; EventMentionSet * ems = st -> getEventMentionSet ( ) ; bool is_victim = false ; for ( int e = 0 ; e < ems -> getNEventMentions ( ) ; e ++ ) { const EventMention * em = ems -> getEventMention ( e ) ; for ( int a = 0 ; a < em -> getNArgs ( ) ; a ++ ) { if ( em -> getNthArgRole ( a ) == Symbol ( L" " ) && em -> getNthArgMention ( a ) == potentialDescMention ) { is_victim = true ; break ; } } } if ( ! is_victim ) return ; Entity * potentialDescEnt = ents -> getEntityByMention ( potentialDescMention -> getUID ( ) ) ; for ( int m = 0 ; m < potentialDescEnt -> getNMentions ( ) ; m ++ ) { if ( ents -> getMention ( potentialDescEnt -> getMention ( m ) ) -> getMentionType ( ) == Mention :: NAME ) { return ; } } SentenceTheory * nextSentence = docTheory -> getSentenceTheory ( sent_no + 1 ) ; const MentionSet * nextMS = nextSentence -> getMentionSet ( ) ; const Mention * nameMention = 0 ; for ( int m = 0 ; m < nextMS -> getNMentions ( ) ; m ++ ) { if ( nextMS -> getMention ( m ) -> getMentionType ( ) == Mention :: NAME ) { if ( nextMS -> getMention ( m ) -> getEntityType ( ) == potentialDescMention -> getEntityType ( ) ) { if ( nameMention != 0 ) return ; else nameMention = nextMS -> getMention ( m ) ; } } } if ( nameMention == 0 ) return ; Entity * nameEnt = ents -> getEntityByMention ( nameMention -> getUID ( ) ) ; if ( nameEnt == 0 ) return ; std :: set < int > descIDSet ; descIDSet . insert ( potentialDescEnt -> getID ( ) ) ; ElfMultiDoc :: merge_entities_in_map ( docTheory , nameEnt -> getID ( ) , descIDSet ) ; }
Call ElfMultiDoc::merge_entities_in_map() on the named entity for the given mention (which we know refers to a person) in the given sentence,
 given that the following criteria are met:
 - entity is described in an event mention in this sentence as a victim
 - entity is named
 - sentence has only one name mention
Call ElfMultiDoc :: merge_entities_in_map () on the named entity for the given mention ( which we know refers to a person ) in the given sentence given that the following criteria are met : - entity is described in an event mention in this sentence as a victim - entity is named - sentence has only one name mention
// don't act on "descriptor" mentions with names
 // don't act on sentences with more than one name
 /*SessionLogger::info("LEARNIT") << "\nLinkage " << potentialDescMention->getEntityType().getName() << ": ";
	SessionLogger::info("LEARNIT") << "Sentence #1: " 
		<< docTheory->getSentenceTheory(sent_no)->getPrimaryParse()->getRoot()->toDebugTextString() << "\n";
	SessionLogger::info("LEARNIT") << "Sentence #2: " 
		<< docTheory->getSentenceTheory(sent_no+1)->getPrimaryParse()->getRoot()->toDebugTextString() << "\n";
	SessionLogger::info("LEARNIT") << "Mention #1: " << potentialDescMention->getNode()->toDebugTextString() << "\n";
	SessionLogger::info("LEARNIT") << "Mention #2: " << nameMention->getNode()->toDebugTextString() << "\n\n";*/