src/Generic/edt/discmodel/DTCorefTrainer.cpp
/** This function now automatically adds suffixes to models based on the model type (e.g. maxent).
  * This is so that one could run a combination model where multiple types of models are loaded
  * simultaneously without having separate parameters for each.
  */
This function now automatically adds suffixes to models based on the model type .
This is so that one could run a combination model where multiple types of models are loaded
simultaneously without having separate parameters for each.
This function now automatically adds suffixes to models based on the model type . This is so that one could run a combination model where multiple types of models are loaded simultaneously without having separate parameters for each .
void DTCorefTrainer::writeWeights(int epoch) {
	if (epoch != -1 && _print_model_every_epoch == false)
		return;
	UTF8OutputStream out;
	std::string modeltype;
	char file[600];
	if (MODEL_TYPE == MAX_ENT) {
		if (epoch == -1)
			sprintf(file, "%s-maxent", _model_file.c_str());
		else
			sprintf(file, "%s-epoch-%d-maxent", _model_file.c_str(), epoch);
	} else if (MODEL_TYPE == P1) {
		if (epoch == -1)
			sprintf(file, "%s-p1", _model_file.c_str());
		else
			sprintf(file, "%s-epoch-%d-p1", _model_file.c_str(), epoch);
	} else if (MODEL_TYPE == P1_RANKING) {
		if (epoch == -1)
			sprintf(file, "%s-rank", _model_file.c_str());
		else
			sprintf(file, "%s-epoch-%d-rank", _model_file.c_str(), epoch);
	}
	out.open(file);
	if (out.fail()) {
		throw UnexpectedInputException("DTCorefTrainer::writeWeights()",
			"Could not open model file for writing");
	}
	dumpTrainingParameters(out);
	if (MODEL_TYPE == MAX_ENT)
		DTFeature::writeWeights(*_maxEntWeights, out);
	else if (MODEL_TYPE == P1 || MODEL_TYPE == P1_RANKING)
		DTFeature::writeSumWeights(*_p1Weights, out);
	out.close();
}
void DTCorefTrainer :: writeWeights ( int epoch ) { if ( epoch != -1 && _print_model_every_epoch == false ) return ; UTF8OutputStream out ; std :: string modeltype ; char file [ 600 ] ; if ( MODEL_TYPE == MAX_ENT ) { if ( epoch == -1 ) sprintf ( file , " " , _model_file . c_str ( ) ) ; else sprintf ( file , " " , _model_file . c_str ( ) , epoch ) ; } else if ( MODEL_TYPE == P1 ) { if ( epoch == -1 ) sprintf ( file , " " , _model_file . c_str ( ) ) ; else sprintf ( file , " " , _model_file . c_str ( ) , epoch ) ; } else if ( MODEL_TYPE == P1_RANKING ) { if ( epoch == -1 ) sprintf ( file , " " , _model_file . c_str ( ) ) ; else sprintf ( file , " " , _model_file . c_str ( ) , epoch ) ; } out . open ( file ) ; if ( out . fail ( ) ) { throw UnexpectedInputException ( " " , " " ) ; } dumpTrainingParameters ( out ) ; if ( MODEL_TYPE == MAX_ENT ) DTFeature :: writeWeights ( * _maxEntWeights , out ) ; else if ( MODEL_TYPE == P1 || MODEL_TYPE == P1_RANKING ) DTFeature :: writeSumWeights ( * _p1Weights , out ) ; out . close ( ) ; }
This function now automatically adds suffixes to models based on the model type (e.g.
This function now automatically adds suffixes to models based on the model type ( e . g .