src/Generic/actors/ActorMentionFinder.cpp
// Version of createProperNounActorMention specifically for software

Version of createProperNounActorMention specifically for software
Version of createProperNounActorMention specifically for software
ActorMention_ptr ActorMentionFinder::createSoftwareMention(
	const ActorMatch &match, const SentenceTheory *sentTheory, Symbol sourceNote,
	bool &head_match, bool &country_the_plural) 
{
	const Mention *mention = getCoveringNameDescMention(sentTheory, match.start_token, match.end_token);
	head_match = (mention != 0);
	if (!head_match) {
		const SynNode *parseRoot = sentTheory->getPrimaryParse()->getRoot();
		const SynNode *coveringNode = parseRoot->getCoveringNodeFromTokenSpan(match.start_token, match.end_token);
		if (coveringNode->getParent() && coveringNode->getParent()->getParent() && 
			(coveringNode->getParent()->getParent()->getTag() == NPP_SYM)) {
			coveringNode = coveringNode->getParent()->getParent();
			mention = getCoveringNameDescMention(sentTheory, coveringNode);
			if (mention && (_verbosity > 4)) {
				SessionLogger::info("ICEWS") << "    Non-head match: mention = ["
					<< mention->toCasedTextString() << "].  pattern match = ["
					<< sentTheory->getTokenSequence()->toString(match.start_token, match.end_token) 
					<< "], head = [" << coveringNode->getHead()->toCasedTextString(sentTheory->getTokenSequence()) << "]";
			}
		}
	}
	if (!mention) {
		return ActorMention_ptr();
	}
	if (_only_match_names && mention->getMentionType() != Mention::NAME) {
		return ActorMention_ptr();
	}
	const SynNode *node = mention->getAtomicHead();
	bool same_start_tok = (node->getStartToken() == match.start_token);
	bool same_end_tok = (node->getEndToken() == match.end_token);
	if (!(same_start_tok && same_end_tok)) {
		const char* context = "a piece of software";
		int start_tok = node->getStartToken();
		int end_tok = node->getEndToken();
		if (!(match.start_token >= start_tok) && (match.end_token <= end_tok)) {
			return ActorMention_ptr();
		}
	}
	ActorMention_ptr actorMention;
	if (match.code == BLOCK_ACTOR_SYM) {
		actorMention = boost::make_shared<ActorMention>(sentTheory, mention, BLOCK_ACTOR_SYM);
	} else {
		actorMention = boost::make_shared<ProperNounActorMention>(sentTheory, mention, sourceNote,
			ActorMention::ActorIdentifiers(match, _actorInfo->getActorName(match.id), _actorTokenMatcher->patternRequiresContext(match.patternId)));
	}
	if (!same_end_tok)
		actorMention->addSourceNote(PATTERN_END_IS_NOT_MENTION_END_SYM);
	if (_require_entity_type_match) {
		if (ProperNounActorMention_ptr pn_actor = boost::dynamic_pointer_cast<ProperNounActorMention>(actorMention)) {
			if (!(mention->getEntityType().getName() == _actorInfo->getEntityTypeForActor(pn_actor->getActorId()))) {
				return ActorMention_ptr();
			}
		}
	}
	return actorMention;
}
ActorMention_ptr ActorMentionFinder :: createSoftwareMention ( const ActorMatch & match , const SentenceTheory * sentTheory , Symbol sourceNote , bool & head_match , bool & country_the_plural ) { const Mention * mention = getCoveringNameDescMention ( sentTheory , match . start_token , match . end_token ) ; head_match = ( mention != 0 ) ; if ( ! head_match ) { const SynNode * parseRoot = sentTheory -> getPrimaryParse ( ) -> getRoot ( ) ; const SynNode * coveringNode = parseRoot -> getCoveringNodeFromTokenSpan ( match . start_token , match . end_token ) ; if ( coveringNode -> getParent ( ) && coveringNode -> getParent ( ) -> getParent ( ) && ( coveringNode -> getParent ( ) -> getParent ( ) -> getTag ( ) == NPP_SYM ) ) { coveringNode = coveringNode -> getParent ( ) -> getParent ( ) ; mention = getCoveringNameDescMention ( sentTheory , coveringNode ) ; if ( mention && ( _verbosity > 4 ) ) { SessionLogger :: info ( " " ) << " " << mention -> toCasedTextString ( ) << " " << sentTheory -> getTokenSequence ( ) -> toString ( match . start_token , match . end_token ) << " " << coveringNode -> getHead ( ) -> toCasedTextString ( sentTheory -> getTokenSequence ( ) ) << " " ; } } } if ( ! mention ) { return ActorMention_ptr ( ) ; } if ( _only_match_names && mention -> getMentionType ( ) != Mention :: NAME ) { return ActorMention_ptr ( ) ; } const SynNode * node = mention -> getAtomicHead ( ) ; bool same_start_tok = ( node -> getStartToken ( ) == match . start_token ) ; bool same_end_tok = ( node -> getEndToken ( ) == match . end_token ) ; if ( ! ( same_start_tok && same_end_tok ) ) { const char * context = " " ; int start_tok = node -> getStartToken ( ) ; int end_tok = node -> getEndToken ( ) ; if ( ! ( match . start_token >= start_tok ) && ( match . end_token <= end_tok ) ) { return ActorMention_ptr ( ) ; } } ActorMention_ptr actorMention ; if ( match . code == BLOCK_ACTOR_SYM ) { actorMention = boost :: make_shared < ActorMention > ( sentTheory , mention , BLOCK_ACTOR_SYM ) ; } else { actorMention = boost :: make_shared < ProperNounActorMention > ( sentTheory , mention , sourceNote , ActorMention :: ActorIdentifiers ( match , _actorInfo -> getActorName ( match . id ) , _actorTokenMatcher -> patternRequiresContext ( match . patternId ) ) ) ; } if ( ! same_end_tok ) actorMention -> addSourceNote ( PATTERN_END_IS_NOT_MENTION_END_SYM ) ; if ( _require_entity_type_match ) { if ( ProperNounActorMention_ptr pn_actor = boost :: dynamic_pointer_cast < ProperNounActorMention > ( actorMention ) ) { if ( ! ( mention -> getEntityType ( ) . getName ( ) == _actorInfo -> getEntityTypeForActor ( pn_actor -> getActorId ( ) ) ) ) { return ActorMention_ptr ( ) ; } } } return actorMention ; }
Version of createProperNounActorMention specifically for software
Version of createProperNounActorMention specifically for software
// If the matched phrase isn't the head of a mention, see if it's a non-head
 // child of one.  This can occur for mis-parses, and in a few other cases.
 // If no such mention is found, then give up.
 //std::cout << "returning--couldn't find a mention\n";
 // This is currently only set when matching using an AWAKE database
 //std::cout << "returning--not a name\n";
 //return an empty mention if the match is not fully contained within the mention
 //std::cout << "match is not contained within mention...returning\n";
 // Construct a proper noun actor mention that links the 
 // actor mention from match with the entity mention.
 // If we're explicitly blocking this agent, then return an empty 
 // ActorMention; this will be discarded at the end of processing.
 // This is currently only set when matching using an AWAKE database
 //LT: changed this line to avoid having to edit entityTypeMatches
 //if (!entityTypeMatches(pn_actor, mention->getEntityType())) {
