53 static const arg_t defn[] = {
57 "Shows the usage of the tool"},
62 "Base in which all log-likelihoods calculated" },
67 "Input language model file (required)"},
72 "Output language model file (required)"},
77 "Input language model format (will guess if not specified)"},
82 "Output language model file (will guess if not specified)"},
87 "Input language model text encoding (no conversion done if not specified)"},
92 "Output language model text encoding"},
97 "Ether 'lower' or 'upper' - case fold to lower/upper case (NOT UNICODE AWARE)" },
102 "Use memory-mapped I/O for reading binary LM files"},
107 "Verbosity level for debugging messages"
110 { NULL, 0, NULL, NULL }
116 E_INFO(
"Usage: %s -i <input.lm> \\\n", pgm);
125 main(
int argc,
char *argv[])
133 if ((config =
cmd_ln_parse_r(NULL, defn, argc, argv, TRUE)) == NULL)
144 (cmd_ln_float64_r(config,
"-logbase"), 0, 0)) == NULL) {
145 E_FATAL(
"Failed to initialize log math\n");
149 E_ERROR(
"Please specify both input and output models\n");
189 E_ERROR(
"Failed to recode language model from %s to %s\n",
198 if (0 == strcmp(kase,
"lower")) {
201 else if (0 == strcmp(kase,
"upper")) {
205 E_ERROR(
"Unknown value for -case: %s\n", kase);
212 E_ERROR(
"Failed to write language model in format %s to %s\n",
Command-line and other configurationparsing and handling.
SPHINXBASE_EXPORT ngram_model_t * ngram_model_read(cmd_ln_t *config, const char *file_name, ngram_file_type_t file_type, logmath_t *lmath)
Read an N-Gram model from a file on disk.
Miscellaneous useful string functions.
SPHINXBASE_EXPORT int ngram_model_write(ngram_model_t *model, const char *file_name, ngram_file_type_t format)
Write an N-Gram model to disk.
SPHINXBASE_EXPORT int ngram_model_casefold(ngram_model_t *model, int kase)
Case-fold word strings in an N-Gram model.
SPHINXBASE_EXPORT int err_set_debug_level(int level)
Set debugging verbosity level.
#define E_INFO
Print logging information to standard error stream.
Sphinx's memory allocation/deallocation routines.
SPHINXBASE_EXPORT cmd_ln_t * cmd_ln_parse_r(cmd_ln_t *inout_cmdln, arg_t const *defn, int32 argc, char *argv[], int32 strict)
Parse a list of strings into argumetns.
#define ARG_STRING
String argument (optional).
SPHINXBASE_EXPORT int ngram_model_free(ngram_model_t *model)
Release memory associated with an N-Gram model.
SPHINXBASE_EXPORT char const * cmd_ln_str_r(cmd_ln_t *cmdln, char const *name)
Retrieve a string from a command-line object.
#define REQARG_STRING
Required string argument.
SPHINXBASE_EXPORT logmath_t * logmath_init(float64 base, int shift, int use_table)
Initialize a log math computation table.
SPHINXBASE_EXPORT char const * ngram_type_to_str(int type)
Get the canonical name for an N-Gram file type.
#define E_INFOCONT
Print logging information without header, to standard error stream.
Implementation of logging routines.
#define ARG_BOOLEAN
Boolean (true/false) argument (optional).
Argument definition structure.
SPHINXBASE_EXPORT ngram_file_type_t ngram_str_to_type(const char *str_name)
Get the N-Gram file type from a string.
Opaque structure used to hold the results of command-line parsing.
#define E_FATAL
Exit with non-zero status after error message.
#define E_ERROR
Print error message to standard error stream.
SPHINXBASE_EXPORT ngram_file_type_t ngram_file_name_to_type(const char *file_name)
Guess the file type for an N-Gram model from the filename.
#define cmd_ln_boolean_r(c, n)
Retrieve a boolean value from a command-line object.
cmd_ln_t * config
Configuration parameters.
Common implementation of ngram_model_t.
Fast integer logarithmic addition operations.
Determine file type automatically.
file IO related operations.
SPHINXBASE_EXPORT int ngram_model_recode(ngram_model_t *model, const char *from, const char *to)
Re-encode word strings in an N-Gram model.