src/util.cpp
//Check whether the user defined arguments are valid
Check whether the user defined arguments are valid
Check whether the user defined arguments are valid
bool Option::CheckArgs()
{
	if (!Util::IsFileExist(train_file))
	{
		printf("Train corpus does not exist\n");
		return false;
	}
	if (!Util::IsFileExist(read_vocab_file))
	{
		printf("Vocab file does not exist\n");
		return false;
	}
	if (output_binary && (binary_embedding_file == NULL || outputlayer_binary_file == NULL))
	{
		printf("Binary output file name not specified\n");
		return false;
	}
	if (output_binary % 2 == 0 && (text_embedding_file == NULL || outputlayer_text_file == NULL))
	{
		printf("Text output file name not specified\n");
		return false;
	}
	if (huff_tree_file == NULL)
	{
		printf("Huffman tree file name not speficied\n");
		return false;
	}
	if (stopwords && !Util::IsFileExist(sw_file))
	{
		printf("Stop words file does not exist\n");
		return false;
	}
	if (init_sense_prior_momentum < -eps || init_sense_prior_momentum >= 1)
	{
		printf("Init momentum %.4f out of range, must lie between 0.0 and 1.0\n", init_sense_prior_momentum);
		return false;
	}
	if (top_ratio < -eps || top_ratio >= 1)
	{
		printf("Top ratio %.4f out of range, must lie between 0.0 and 1.0\n", init_sense_prior_momentum);
		return false;
	}
	if (sense_num_multi > MAX_SENSE_CNT)
	{
		printf("Sense number is too big, the maximum value is 50\n");
		return false;
	}
	if (fabs(static_cast<real>(max_delay)) > eps)
	{
		printf("Warning: better set max_delay to 0!\n");
	}
	return true;
}
bool Option :: CheckArgs ( ) { if ( ! Util :: IsFileExist ( train_file ) ) { printf ( " \n " ) ; return false ; } if ( ! Util :: IsFileExist ( read_vocab_file ) ) { printf ( " \n " ) ; return false ; } if ( output_binary && ( binary_embedding_file == NULL || outputlayer_binary_file == NULL ) ) { printf ( " \n " ) ; return false ; } if ( output_binary % 2 == 0 && ( text_embedding_file == NULL || outputlayer_text_file == NULL ) ) { printf ( " \n " ) ; return false ; } if ( huff_tree_file == NULL ) { printf ( " \n " ) ; return false ; } if ( stopwords && ! Util :: IsFileExist ( sw_file ) ) { printf ( " \n " ) ; return false ; } if ( init_sense_prior_momentum < - eps || init_sense_prior_momentum >= 1 ) { printf ( " \n " , init_sense_prior_momentum ) ; return false ; } if ( top_ratio < - eps || top_ratio >= 1 ) { printf ( " \n " , init_sense_prior_momentum ) ; return false ; } if ( sense_num_multi > MAX_SENSE_CNT ) { printf ( " \n " ) ; return false ; } if ( fabs ( static_cast < real > ( max_delay ) ) > eps ) { printf ( " \n " ) ; } return true ; }
Check whether the user defined arguments are valid
Check whether the user defined arguments are valid