src/Generic/edt/discmodel/DTCorefLinker.cpp
// set up to link. This method doesn't do any of the actual processing - it just provides a way
// for multiple paths to get through

set up to link. This method doesn't do any of the actual processing - it just provides a way
for multiple paths to get through
set up to link . This method doesn ' t do any of the actual processing - it just provides a way for multiple paths to get through
int DTCorefLinker::linkMention (LexEntitySet * currSolution, MentionUID currMentionUID,
								 EntityType linkType, LexEntitySet *results[], int max_results)
{
	LexEntitySet *newSet = NULL;
	EntityGuess guesses[64];
	Mention *currMention = currSolution->getMention(currMentionUID);
	if (_debugStream.isActive()) {
		_debugStream << L"\nPROCESSING Mention #" << currMention->getUID() << L": ";
		_debugStream << currMention->getNode()->toTextString() << L"\n";
	}
	int nGuesses = guessEntity(currSolution, currMention, linkType, guesses, 64);
	if(nGuesses>max_results) nGuesses = max_results;
	for (int i = 0; i < nGuesses; i++) {
		newSet = currSolution->fork();
		if (guesses[i].id == EntityGuess::NEW_ENTITY ||
			!guesses[i].type.isRecognized()) 
		{ 
			if (!guesses[i].type.isRecognized()) {
				if (_debugStream.isActive()) 
					_debugStream << L"OUTCOME: NOT CREATING A NEW ENTITY BECAUSE OF LINKING TO NON-ACE ENTITY #"<<guesses[i].id<<"\n";
			}
			else {
				newSet->addNew(currMention->getUID(), linkType);
				if (_debugStream.isActive())
					_debugStream << L"OUTCOME: CREATED NEW ENTITY #" << newSet->getNEntities() - 1 << "\n";
			}
			Mention *newMention = newSet->getMention(currMention->getUID());
			newMention->setLinkConfidence(guesses[i].linkConfidence);
		}
		else {
			newSet->add(currMention->getUID(), guesses[i].id);
			Mention *newMention = newSet->getMention(currMention->getUID());
			if(!_filter_by_entity_type && newMention->getEntityType()!=guesses[i].type) {
				newMention->setEntityType(guesses[i].type);
				newMention->setEntitySubtype(EntitySubtype::getDefaultSubtype(guesses[i].type));
			}
			newMention->setLinkConfidence(guesses[i].linkConfidence);
			if (_debugStream.isActive())
				_debugStream << L"OUTCOME: LINKED TO ENTITY #"  << guesses[i].id << " score: "<< guesses[i].score <<"\n";
		}
		newSet->setScore(newSet->getScore() + static_cast<float>(guesses[i].score));
		results[i] = newSet;
		newSet->customDebugPrint(_debugStream);
	}
	if (_debugStream.isActive())
		_debugStream << L"\nDONE PROCESSING MENTION #" << currMention->getUID() << "\n\n";
	return nGuesses;
}
int DTCorefLinker :: linkMention ( LexEntitySet * currSolution , MentionUID currMentionUID , EntityType linkType , LexEntitySet * results [ ] , int max_results ) { LexEntitySet * newSet = NULL ; EntityGuess guesses [ 64 ] ; Mention * currMention = currSolution -> getMention ( currMentionUID ) ; if ( _debugStream . isActive ( ) ) { _debugStream << L" \n " << currMention -> getUID ( ) << L" " ; _debugStream << currMention -> getNode ( ) -> toTextString ( ) << L" \n " ; } int nGuesses = guessEntity ( currSolution , currMention , linkType , guesses , 64 ) ; if ( nGuesses > max_results ) nGuesses = max_results ; for ( int i = 0 ; i < nGuesses ; i ++ ) { newSet = currSolution -> fork ( ) ; if ( guesses [ i ] . id == EntityGuess :: NEW_ENTITY || ! guesses [ i ] . type . isRecognized ( ) ) { if ( ! guesses [ i ] . type . isRecognized ( ) ) { if ( _debugStream . isActive ( ) ) _debugStream << L" " << guesses [ i ] . id << " \n " ; } else { newSet -> addNew ( currMention -> getUID ( ) , linkType ) ; if ( _debugStream . isActive ( ) ) _debugStream << L" " << newSet -> getNEntities ( ) - 1 << " \n " ; } Mention * newMention = newSet -> getMention ( currMention -> getUID ( ) ) ; newMention -> setLinkConfidence ( guesses [ i ] . linkConfidence ) ; } else { newSet -> add ( currMention -> getUID ( ) , guesses [ i ] . id ) ; Mention * newMention = newSet -> getMention ( currMention -> getUID ( ) ) ; if ( ! _filter_by_entity_type && newMention -> getEntityType ( ) != guesses [ i ] . type ) { newMention -> setEntityType ( guesses [ i ] . type ) ; newMention -> setEntitySubtype ( EntitySubtype :: getDefaultSubtype ( guesses [ i ] . type ) ) ; } newMention -> setLinkConfidence ( guesses [ i ] . linkConfidence ) ; if ( _debugStream . isActive ( ) ) _debugStream << L" " << guesses [ i ] . id << " " << guesses [ i ] . score << " \n " ; } newSet -> setScore ( newSet -> getScore ( ) + static_cast < float > ( guesses [ i ] . score ) ) ; results [ i ] = newSet ; newSet -> customDebugPrint ( _debugStream ) ; } if ( _debugStream . isActive ( ) ) _debugStream << L" \n " << currMention -> getUID ( ) << " \n \n " ; return nGuesses ; }
set up to link.
set up to link .
//	int nGuesses = guessEntity(currSolution, currMention, linkType, guesses, 
 //								max_results>64 ? 64: max_results);
 // when used with non-ACE candidates for no-link
 /*
				// +++ JJO 08 Aug 2011 +++
				// Word inclusion
				if (_strict) {
					const SynNode *currNode = currMention->getNode();
					int currNWords = currMention->getNWords();
					Symbol *currWords = _new Symbol[512];
					currNode->getTerminalSymbols(currWords, currNWords);
					Entity *entity = newSet->getEntityByMention(currMention->getUID());
					entity->addWords(currWords, currNWords);
					delete [] currWords;
				}
				// --- JJO 08 Aug 2011 ---
				*/ /*
			// +++ JJO 08 Aug 2011 +++
			// Word inclusion (same as above)
			if (_strict) {
				const SynNode *currNode = currMention->getNode();
				int currNWords = currMention->getNWords();
				Symbol *currWords = _new Symbol[512];
				currNode->getTerminalSymbols(currWords, currNWords);
				Entity *entity = newSet->getEntityByMention(currMention->getUID());
				entity->addWords(currWords, currNWords);
				delete [] currWords;
			}
			// --- JJO 08 Aug 2011 ---
			*/