src/PredFinder/common/ElfMultiDoc.cpp
// called by get_mapped_arg(); always returns either a bound URI or an empty string

called by get_mapped_arg(); always returns either a bound URI or an empty string
called by get_mapped_arg () ; always returns either a bound URI or an empty string
std::wstring ElfMultiDoc::get_mapped_arg_for_nfl_team(const std::wstring & best_name, const std::wstring & type_string, 
											const DocTheory* doc_theory, const Entity* entity) {
	if(_eid_to_bound_uris.size() != 0 && _eid_to_bound_uris.find(entity->getID())!= _eid_to_bound_uris.end()){
		return (*_eid_to_bound_uris[entity->getID()].begin());
	}
	else if(_eid_to_bound_uris_merged.size() != 0 && 
		_eid_to_bound_uris_merged.find(entity->getID())!= _eid_to_bound_uris_merged.end()){
		return (*_eid_to_bound_uris_merged[entity->getID()].begin());
	}
	else{
		std::wstring docid = std::wstring(doc_theory->getDocument()->getName().to_string());
		std::wstring uri = find_bound_uri_from_name_w_or_wo_docid(best_name, docid);
		if(uri != L""){
			return uri;
		}
		std::wstring name_uri, desc_uri, node_uri, name_str, desc_str, node_str;
		bool found_newyork = false;
		const EntitySet* entity_set = doc_theory->getEntitySet();
		for(int i = 0; i < entity->getNMentions(); i++){
			const Mention* mention = entity_set->getMention(entity->getMention(i));
			if(mention->getMentionType() == Mention::NAME && mention->getHead() != 0){
				std::wstring nstr = mention->getHead()->toTextString();
				std::wstring uri = find_bound_uri_from_name_w_or_wo_docid(nstr, docid);
				if(uri != L"" && name_uri == L""){
					name_str = nstr;
					name_uri = uri;
				} 
				else if(uri == L""){
					std::wstring normalized_best_string = UnicodeUtil::normalizeTextString(nstr);
					if(normalized_best_string == L"new york")
						found_newyork = true;
				}
			}
			if(mention->getMentionType() == Mention::DESC && mention->getHead() != 0){
				std::wstring nstr = mention->getHead()->toTextString();
				std::wstring uri = find_bound_uri_from_name_w_or_wo_docid(nstr, docid);
				if(uri != L"" && desc_uri == L""){
					desc_str = nstr;
					desc_uri = uri;
				}
			}
			if(mention->getNode() != 0){
				std::wstring nstr = mention->getNode()->toTextString();
				std::wstring uri = find_bound_uri_from_name_w_or_wo_docid(nstr, docid);
				if(uri != L"" && node_uri == L""){
					node_str = nstr;
					node_uri = uri;
				}
			}
		}
		if(name_uri != L""){
			return name_uri;
		}
		else if(desc_uri != L""){
			return desc_uri;
		}
		else if(node_uri != L""){
			return node_uri;
		}
		else if(found_newyork){
			return get_best_name_for_ny_nfl_team(doc_theory);
		}
		else {
			return L"";
		}
	}
}
std :: wstring ElfMultiDoc :: get_mapped_arg_for_nfl_team ( const std :: wstring & best_name , const std :: wstring & type_string , const DocTheory * doc_theory , const Entity * entity ) { if ( _eid_to_bound_uris . size ( ) != 0 && _eid_to_bound_uris . find ( entity -> getID ( ) ) != _eid_to_bound_uris . end ( ) ) { return ( * _eid_to_bound_uris [ entity -> getID ( ) ] . begin ( ) ) ; } else if ( _eid_to_bound_uris_merged . size ( ) != 0 && _eid_to_bound_uris_merged . find ( entity -> getID ( ) ) != _eid_to_bound_uris_merged . end ( ) ) { return ( * _eid_to_bound_uris_merged [ entity -> getID ( ) ] . begin ( ) ) ; } else { std :: wstring docid = std :: wstring ( doc_theory -> getDocument ( ) -> getName ( ) . to_string ( ) ) ; std :: wstring uri = find_bound_uri_from_name_w_or_wo_docid ( best_name , docid ) ; if ( uri != L" " ) { return uri ; } std :: wstring name_uri , desc_uri , node_uri , name_str , desc_str , node_str ; bool found_newyork = false ; const EntitySet * entity_set = doc_theory -> getEntitySet ( ) ; for ( int i = 0 ; i < entity -> getNMentions ( ) ; i ++ ) { const Mention * mention = entity_set -> getMention ( entity -> getMention ( i ) ) ; if ( mention -> getMentionType ( ) == Mention :: NAME && mention -> getHead ( ) != 0 ) { std :: wstring nstr = mention -> getHead ( ) -> toTextString ( ) ; std :: wstring uri = find_bound_uri_from_name_w_or_wo_docid ( nstr , docid ) ; if ( uri != L" " && name_uri == L" " ) { name_str = nstr ; name_uri = uri ; } else if ( uri == L" " ) { std :: wstring normalized_best_string = UnicodeUtil :: normalizeTextString ( nstr ) ; if ( normalized_best_string == L" " ) found_newyork = true ; } } if ( mention -> getMentionType ( ) == Mention :: DESC && mention -> getHead ( ) != 0 ) { std :: wstring nstr = mention -> getHead ( ) -> toTextString ( ) ; std :: wstring uri = find_bound_uri_from_name_w_or_wo_docid ( nstr , docid ) ; if ( uri != L" " && desc_uri == L" " ) { desc_str = nstr ; desc_uri = uri ; } } if ( mention -> getNode ( ) != 0 ) { std :: wstring nstr = mention -> getNode ( ) -> toTextString ( ) ; std :: wstring uri = find_bound_uri_from_name_w_or_wo_docid ( nstr , docid ) ; if ( uri != L" " && node_uri == L" " ) { node_str = nstr ; node_uri = uri ; } } } if ( name_uri != L" " ) { return name_uri ; } else if ( desc_uri != L" " ) { return desc_uri ; } else if ( node_uri != L" " ) { return node_uri ; } else if ( found_newyork ) { return get_best_name_for_ny_nfl_team ( doc_theory ) ; } else { return L" " ; } } }
called by get_mapped_arg(); always returns either a bound URI or an empty string
called by get_mapped_arg () ; always returns either a bound URI or an empty string
//horrible, horrible hack but for NFLTeams we really want to force to the NFL bound uris
 //SessionLogger::info("LEARNIT")<<"using a name: "<<best_name<<", "<<name_str<<
 //	"--> n="<<name_uri<<", d="<<desc_uri<<" x="<<node_uri<<std::endl;
 //SessionLogger::info("LEARNIT")<<"using a desc: "<<best_name<<", "<<desc_str<<
 //	"--> n="<<name_uri<<", d="<<desc_uri<<" x="<<node_uri<<std::endl;
 //SessionLogger::info("LEARNIT")<<"using a node: "<<best_name<<", "<<node_str<<
 //	"--> n="<<name_uri<<", d="<<desc_uri<<" x="<<node_uri<<std::endl;
