src/ProfileGenerator/Profile.cpp
//
// Prepare (i.e. finalize) profile for upload (generate teaser bio, set confidences, etc.)
// 
// Prints to screen for debugging if print_to_screen is true
//

Prepare  profile for upload (generate teaser bio, set confidences, etc.)
Prints to screen for debugging if print_to_screen is true
Prepare profile for upload ( generate teaser bio set confidences etc . ) Prints to screen for debugging if print_to_screen is true
void Profile::prepareForUpload(ProfileConfidence_ptr confidenceModel, bool print_to_screen) {
	std::pair<std::string, ProfileSlot_ptr> typeSlotPair, newTypeSlotPair;
	std::list<std::pair<std::string, ProfileSlot_ptr> > sortedSlots;
	for (ProfileSlotMap::iterator iter = _slots.begin(); iter != _slots.end(); iter++) {
		newTypeSlotPair = *iter;
		bool inserted = false;
		for (std::list<std::pair<std::string,ProfileSlot_ptr> >::iterator typeSlotPairPtr = sortedSlots.begin(); typeSlotPairPtr != sortedSlots.end(); typeSlotPairPtr++) {
			if (typeSlotPairPtr->second->getRank() > newTypeSlotPair.second->getRank()) {
				sortedSlots.insert(typeSlotPairPtr, newTypeSlotPair);
				inserted = true;
				break;
			}
		}
		if (!inserted)
			sortedSlots.push_back(newTypeSlotPair);
	}
	BOOST_FOREACH(typeSlotPair, sortedSlots) {
		if (typeSlotPair.second->getUniqueId() == ProfileSlot::DESCRIPTION_UNIQUE_ID)
			continue;
		typeSlotPair.second->generateOutputHypotheses(shared_from_this(), print_to_screen);
	}
	ProfileSlot_ptr descriptionSlot = getExistingSlot(ProfileSlot::DESCRIPTION_UNIQUE_ID);
	if (descriptionSlot != ProfileSlot_ptr()) {
		descriptionSlot->makeOutOfDate();
		descriptionSlot->generateOutputHypotheses(shared_from_this(), print_to_screen);
	}
	ProfileSlot_ptr teaserBioSlot = getExistingSlot(ProfileSlot::TEASER_BIO_UNIQUE_ID);
	if (teaserBioSlot != ProfileSlot_ptr()) {
		TeaserBiography_ptr teaser_bio = boost::make_shared<TeaserBiography>(shared_from_this());	
		std::wstring nullWString = L"";
		std::string nullString = "";
		if (teaser_bio->getBiography() != L"") {
			PGFact_ptr fact = boost::make_shared<PGFact>();
			PGFactArgument_ptr factArg = boost::make_shared<PGFactArgument>(-1, -1,
				nullString, nullWString, teaser_bio->getBiography(), teaserBioSlot->getAnswerRole(), 1.0, false);
			fact->addArgument(factArg, true);
			teaserBioSlot->addFact(fact, _pgdm);
			teaserBioSlot->generateOutputHypotheses(shared_from_this(), print_to_screen);
		}
	}
	BOOST_FOREACH(typeSlotPair, _slots) {
		std::list<GenericHypothesis_ptr>& hypotheses = typeSlotPair.second->getOutputHypotheses();
		BOOST_FOREACH(GenericHypothesis_ptr hypothesis, hypotheses) {
			hypothesis->setConfidence(1.0);
		}
	}
}
void Profile :: prepareForUpload ( ProfileConfidence_ptr confidenceModel , bool print_to_screen ) { std :: pair < std :: string , ProfileSlot_ptr > typeSlotPair , newTypeSlotPair ; std :: list < std :: pair < std :: string , ProfileSlot_ptr > > sortedSlots ; for ( ProfileSlotMap :: iterator iter = _slots . begin ( ) ; iter != _slots . end ( ) ; iter ++ ) { newTypeSlotPair = * iter ; bool inserted = false ; for ( std :: list < std :: pair < std :: string , ProfileSlot_ptr > > :: iterator typeSlotPairPtr = sortedSlots . begin ( ) ; typeSlotPairPtr != sortedSlots . end ( ) ; typeSlotPairPtr ++ ) { if ( typeSlotPairPtr -> second -> getRank ( ) > newTypeSlotPair . second -> getRank ( ) ) { sortedSlots . insert ( typeSlotPairPtr , newTypeSlotPair ) ; inserted = true ; break ; } } if ( ! inserted ) sortedSlots . push_back ( newTypeSlotPair ) ; } BOOST_FOREACH ( typeSlotPair , sortedSlots ) { if ( typeSlotPair . second -> getUniqueId ( ) == ProfileSlot :: DESCRIPTION_UNIQUE_ID ) continue ; typeSlotPair . second -> generateOutputHypotheses ( shared_from_this ( ) , print_to_screen ) ; } ProfileSlot_ptr descriptionSlot = getExistingSlot ( ProfileSlot :: DESCRIPTION_UNIQUE_ID ) ; if ( descriptionSlot != ProfileSlot_ptr ( ) ) { descriptionSlot -> makeOutOfDate ( ) ; descriptionSlot -> generateOutputHypotheses ( shared_from_this ( ) , print_to_screen ) ; } ProfileSlot_ptr teaserBioSlot = getExistingSlot ( ProfileSlot :: TEASER_BIO_UNIQUE_ID ) ; if ( teaserBioSlot != ProfileSlot_ptr ( ) ) { TeaserBiography_ptr teaser_bio = boost :: make_shared < TeaserBiography > ( shared_from_this ( ) ) ; std :: wstring nullWString = L" " ; std :: string nullString = " " ; if ( teaser_bio -> getBiography ( ) != L" " ) { PGFact_ptr fact = boost :: make_shared < PGFact > ( ) ; PGFactArgument_ptr factArg = boost :: make_shared < PGFactArgument > ( -1 , -1 , nullString , nullWString , teaser_bio -> getBiography ( ) , teaserBioSlot -> getAnswerRole ( ) , 1.0 , false ) ; fact -> addArgument ( factArg , true ) ; teaserBioSlot -> addFact ( fact , _pgdm ) ; teaserBioSlot -> generateOutputHypotheses ( shared_from_this ( ) , print_to_screen ) ; } } BOOST_FOREACH ( typeSlotPair , _slots ) { std :: list < GenericHypothesis_ptr > & hypotheses = typeSlotPair . second -> getOutputHypotheses ( ) ; BOOST_FOREACH ( GenericHypothesis_ptr hypothesis , hypotheses ) { hypothesis -> setConfidence ( 1.0 ) ; } } }
Prepare (i.e.
Prepare ( i . e .
// sort them first, solely for debugging consistency purposes
 // Generate baseline output hypotheses first for all slots except descriptions
 // For cross-slot management of the description slot, so it is not repetitive
 // Now create the teaser biography
 // Last step: set confidences for hypotheses in each slot-- currently a no-op
