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 "Ether 'lower' or 'upper' - case fold to lower/upper case (NOT UNICODE AWARE)" },
92 "Use memory-mapped I/O for reading binary LM files"},
97 "Verbosity level for debugging messages" 100 { NULL, 0, NULL, NULL }
106 E_INFO(
"Usage: %s -i <input.lm> \\\n", pgm);
115 main(
int argc,
char *argv[])
134 (cmd_ln_float64_r(
config,
"-logbase"), 0, 0)) == NULL) {
135 E_FATAL(
"Failed to initialize log math\n");
139 E_ERROR(
"Please specify both input and output models\n");
177 if (0 == strcmp(kase,
"lower")) {
180 else if (0 == strcmp(kase,
"upper")) {
184 E_ERROR(
"Unknown value for -case: %s\n", kase);
191 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.
#define E_INFO(...)
Print logging information to standard error stream.
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.
#define E_ERROR(...)
Print error message to error log.
SPHINXBASE_EXPORT int err_set_debug_level(int level)
Set debugging verbosity level.
Sphinx's memory allocation/deallocation routines.
#define E_INFOCONT(...)
Continue printing the information to standard error stream.
SPHINXBASE_EXPORT int cmd_ln_free_r(cmd_ln_t *cmdln)
Release a command-line argument set and all associated strings.
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 logmath_free(logmath_t *lmath)
Free a log table.
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.
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.
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.
#define E_FATAL(...)
Exit with non-zero status after error message.
Common implementation of ngram_model_t.
Fast integer logarithmic addition operations.
Determine file type automatically.
file IO related operations.