📄 lton_param_0.cc
字号:
// file: lton_param_0.cc//// function to read data from parameter file//// isip include files//#include "lat_to_nbest.h"#include "lat_to_nbest_constants.h"// method: read_params_cc//// arguments:// FILE* fp : (input) file pointer to params file// char_1*& lex_file : (output) name of lexicon file// char_1*& lm_file : (output) name of language model file// char_1*& input_file : (output) name of the input file// char_1*& output_file : (output) name of the output file// int_4& ngram : (output) n-gram order// int_4& nbst : (output) n-best word hyps// int_4& max_paths : (output) max number of partial paths per frame// float_8& beam : (output) beam widths for pruning// float_8& lm_scale : (output) lm scale factor// float_8& wd_penalty : (output) word insertion penalty//// return: a logical flag to indicate success// logical_1 read_params_cc(FILE* fp_a, char_1*& lex_file_a, char_1*& lm_file_a, char_1*& input_file_a, char_1*& output_file_a, int_4& ngram_a, int_4& nbst_a, int_4& max_paths_a, float_8& beam_a, float_8& lm_scale_a, float_8& wd_penalty_a) { // string to hold temporary data // char_1* tmp = new char_1[ISIP_MAX_STRING_LENGTH]; // read data from file // while (fscanf(fp_a, "%s", tmp) != EOF) { // ignore comment lines // if (tmp[0] == (char_1)'#') { fscanf(fp_a, "%[^\n]", tmp); fscanf(fp_a, "%[\n]", tmp); } // read name of lexicon data file // else if (strcmp((char*)tmp, LTON_OP_LEXICON_FILE) == 0) { fscanf(fp_a, "%s", tmp); fscanf(fp_a, "%s", tmp); lex_file_a = new char_1[strlen((char*)tmp) + 1]; strcpy((char*)lex_file_a, (char*)tmp); Decoder::expand_filename_cc(lex_file_a); } // read name of language model data file // else if (strcmp((char*)tmp, LTON_OP_LM_FILE) == 0) { fscanf(fp_a, "%s", tmp); fscanf(fp_a, "%s", tmp); lm_file_a = new char_1[strlen((char*)tmp) + 1]; strcpy((char*)lm_file_a, (char*)tmp); Decoder::expand_filename_cc(lm_file_a); } // read the name of the output file list // else if (strcmp((char*)tmp, LTON_OP_INPUT_LIST) == 0) { fscanf(fp_a, "%s", tmp); fscanf(fp_a, "%s", tmp); input_file_a = new char_1[strlen((char*)tmp) + 1]; strcpy((char*)input_file_a, (char*)tmp); Decoder::expand_filename_cc(input_file_a); } // read the name of the output file list // else if (strcmp((char*)tmp, LTON_OP_OUTPUT_LIST) == 0) { fscanf(fp_a, "%s", tmp); fscanf(fp_a, "%s", tmp); output_file_a = new char_1[strlen((char*)tmp) + 1]; strcpy((char*)output_file_a, (char*)tmp); Decoder::expand_filename_cc(output_file_a); } // read the value for number of nbest paths to output // else if (strcmp((char*)tmp, LTON_OP_NBEST) == 0) { fscanf(fp_a, "%s", tmp); fscanf(fp_a, "%s", tmp); nbst_a = (int_4)atoi((char*)tmp); } // set the beam widths if beam pruning is allowed // else if (strcmp((char*)tmp, LTON_OP_MAX_PATHS) == 0) { fscanf(fp_a, "%s", tmp); fscanf(fp_a, "%s", tmp); max_paths_a = (int_4)atoi((char*)tmp); } // set the beam widths if beam pruning is allowed // else if (strcmp((char*)tmp, LTON_OP_NBEST_BEAM) == 0) { fscanf(fp_a, "%s", tmp); fscanf(fp_a, "%s", tmp); beam_a = (float_8)atof((char*)tmp); } // read the value for lm scale factor // else if (strcmp((char*)tmp, LTON_OP_LMSCALE) == 0) { fscanf(fp_a, "%s", tmp); fscanf(fp_a, "%s", tmp); lm_scale_a = (float_8)atof((char*)tmp); } // read the value for word insertion penalty // else if (strcmp((char*)tmp, LTON_OP_WORDPENALTY) == 0) { fscanf(fp_a, "%s", tmp); fscanf(fp_a, "%s", tmp); wd_penalty_a = (float_8)atof((char*)tmp); } // otherwise ignore the line // else { fscanf(fp_a, "%[^\n]", tmp); fscanf(fp_a, "\n"); } } // delete memory // delete [] tmp; // return gracefully // return ISIP_TRUE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -