src/PredFinder/inference/EIUtils.cpp
/** 
 *  Find the first named mention that matches one of a set of valid name strings.
 *  Please note that the valid name strings must be lowercase.
 **/
Find the first named mention that matches one of a set of valid name strings.
Please note that the valid name strings must be lowercase.
Find the first named mention that matches one of a set of valid name strings . Please note that the valid name strings must be lowercase .
const Mention *EIUtils::findMentionByNameStrings(EIDocData_ptr docData, EntityType et, std::set<std::wstring>& validNames) {
	const DocTheory *docTheory = docData->getDocTheory();
	for (int sentno = 0; sentno < docTheory->getNSentences(); sentno++) {
		MentionSet *ms = docTheory->getSentenceTheory(sentno)->getMentionSet();
		for (int m = 0; m < ms->getNMentions(); m++) {
			const Mention *ment = ms->getMention(m);
			if (ment->getEntityType() != et || ment->getMentionType() != Mention::NAME)
				continue;
			std::wstring nameString = ment->getAtomicHead()->toTextString();
			boost::algorithm::trim(nameString); 
			if (validNames.find(nameString) != validNames.end())
				return ment;
		}
	}
	return 0;
}
const Mention * EIUtils :: findMentionByNameStrings ( EIDocData_ptr docData , EntityType et , std :: set < std :: wstring > & validNames ) { const DocTheory * docTheory = docData -> getDocTheory ( ) ; for ( int sentno = 0 ; sentno < docTheory -> getNSentences ( ) ; sentno ++ ) { MentionSet * ms = docTheory -> getSentenceTheory ( sentno ) -> getMentionSet ( ) ; for ( int m = 0 ; m < ms -> getNMentions ( ) ; m ++ ) { const Mention * ment = ms -> getMention ( m ) ; if ( ment -> getEntityType ( ) != et || ment -> getMentionType ( ) != Mention :: NAME ) continue ; std :: wstring nameString = ment -> getAtomicHead ( ) -> toTextString ( ) ; boost :: algorithm :: trim ( nameString ) ; if ( validNames . find ( nameString ) != validNames . end ( ) ) return ment ; } } return 0 ; }
Find the first named mention that matches one of a set of valid name strings.
Find the first named mention that matches one of a set of valid name strings .
// toTextString() adds an extra space at the end
