src/Generic/names/IdFModel.cpp
/**
 * Given dataTable (a set of events), fill in probability tables (future + history, 
 * # times occured), history tables (history, # times occured), and unique tables 
 * (history, # unique futures given this history). 
 *
 * Calculate the un-backed-off probabilities in the prob tables, then call 
 * deriveTagLambdas() to fill in the lambda tables, using the counts from 
 * the history and unique tables.
 */
Given dataTable (a set of events), fill in probability tables (future + history,
# times occured), history tables (history, # times occured), and unique tables
(history, # unique futures given this history).

Calculate the un-backed-off probabilities in the prob tables, then call
deriveTagLambdas() to fill in the lambda tables, using the counts from
the history and unique tables.
Given dataTable ( a set of events ) fill in probability tables ( future + history # times occured ) history tables ( history # times occured ) and unique tables ( history # unique futures given this history ) . Calculate the un - backed - off probabilities in the prob tables then call deriveTagLambdas () to fill in the lambda tables using the counts from the history and unique tables .
void IdFModel::deriveTagTables(NgramScoreTable* dataTable) {
	if (DECODE) {
		SessionLogger::info("SERIF") << "can't derive tag tables during decode\n";
		return;
	}
	NgramScoreTable::Table::iterator iter;
	float total = 0;
	for (iter = dataTable->get_start(); iter != dataTable->get_end(); ++iter) {
		_tagFullProbabilities->add((*iter).first, (*iter).second);
		_tagFullHistories->add((*iter).first + 1, (*iter).second);
		_tagUniqueCounts->add((*iter).first + 1, 1);
		_tagReducedProbabilities->add((*iter).first, (*iter).second);
		_tagReducedHistories->add((*iter).first + 1, (*iter).second);
		_tagPriors->add((*iter).first, (*iter).second);
		total += (*iter).second;
	}
	for (iter = _tagFullProbabilities->get_start(); iter != _tagFullProbabilities->get_end(); ++iter) {
		float transitions = (*iter).second;
		float histories = _tagFullHistories->lookup((*iter).first + 1);
		(*iter).second = transitions / histories;
	}
	for (iter = _tagReducedProbabilities->get_start(); iter != _tagReducedProbabilities->get_end(); ++iter) {
		float transitions = (*iter).second;
		float histories = _tagReducedHistories->lookup((*iter).first + 1);
		(*iter).second = transitions / histories;
	}
	for (iter = _tagPriors->get_start(); iter != _tagPriors->get_end(); ++iter) {
		(*iter).second = (*iter).second / total;
	}
	deriveTagLambdas();
}
void IdFModel :: deriveTagTables ( NgramScoreTable * dataTable ) { if ( DECODE ) { SessionLogger :: info ( " " ) << " \n " ; return ; } NgramScoreTable :: Table :: iterator iter ; float total = 0 ; for ( iter = dataTable -> get_start ( ) ; iter != dataTable -> get_end ( ) ; ++ iter ) { _tagFullProbabilities -> add ( ( * iter ) . first , ( * iter ) . second ) ; _tagFullHistories -> add ( ( * iter ) . first + 1 , ( * iter ) . second ) ; _tagUniqueCounts -> add ( ( * iter ) . first + 1 , 1 ) ; _tagReducedProbabilities -> add ( ( * iter ) . first , ( * iter ) . second ) ; _tagReducedHistories -> add ( ( * iter ) . first + 1 , ( * iter ) . second ) ; _tagPriors -> add ( ( * iter ) . first , ( * iter ) . second ) ; total += ( * iter ) . second ; } for ( iter = _tagFullProbabilities -> get_start ( ) ; iter != _tagFullProbabilities -> get_end ( ) ; ++ iter ) { float transitions = ( * iter ) . second ; float histories = _tagFullHistories -> lookup ( ( * iter ) . first + 1 ) ; ( * iter ) . second = transitions / histories ; } for ( iter = _tagReducedProbabilities -> get_start ( ) ; iter != _tagReducedProbabilities -> get_end ( ) ; ++ iter ) { float transitions = ( * iter ) . second ; float histories = _tagReducedHistories -> lookup ( ( * iter ) . first + 1 ) ; ( * iter ) . second = transitions / histories ; } for ( iter = _tagPriors -> get_start ( ) ; iter != _tagPriors -> get_end ( ) ; ++ iter ) { ( * iter ) . second = ( * iter ) . second / total ; } deriveTagLambdas ( ) ; }
Given dataTable (a set of events), fill in probability tables (future + history,
 # times occured), history tables (history, # times occured), and unique tables
 (history, # unique futures given this history).
Given dataTable ( a set of events ) fill in probability tables ( future + history # times occured ) history tables ( history # times occured ) and unique tables ( history # unique futures given this history ) .