1
/* ====================================================================
2
* Copyright (c) 1995-2000 Carnegie Mellon University. All rights
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in
14
* the documentation and/or other materials provided with the
17
* This work was supported in part by funding from the Defense Advanced
18
* Research Projects Agency and the National Science Foundation of the
19
* United States of America, and the CMU Sphinx Speech Consortium.
21
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
22
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
25
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
* ====================================================================
36
/*********************************************************************
38
* File: parse_cmd_ln.c
43
* Eric H. Thayer (eht@cs.cmu.edu)
44
*********************************************************************/
46
#include "parse_cmd_ln.h"
48
#include <s3/common.h>
55
#include <sys/types.h>
57
/* defines, parses and (partially) validates the arguments
58
given on the command line */
61
parse_cmd_ln(int argc, char *argv[])
66
const char helpstr[] =
69
Display numerical values of resources generated by Sphinx \n\
70
Current we supoort the following formats \n\
72
-tmatfn : transition matrix \n\
74
-mixwfn : mixture weight file \n\
76
-gaufn : mean or variance \n\
78
-fullgaufn : full covariance \n\
80
-gaucntn : sufficient statistics for mean and diagonal covariance \n\
82
-lambdafn : interpolation weight \n\
84
Currently, some parameters can be specified as intervals such as mixture weight. \n\
86
You can also specified -sigfig the number of significant digits by you would like to see. \n\
88
and normalize the parameters by -norm";
90
const char examplestr[] =
93
Print the mean of a Gaussian: \n\
94
printp -gaufn mean \n\
96
Print the variance of a Gaussian: \n\
99
Print the sufficient statistic: \n\
100
printp -gaucntfn gaucnt: \n\
102
Print the mixture weights: \n\
105
Print the LDA transformation matrix(es): \n\
108
Print the interpolation weight: \n\
109
printp -lambdafn lambda ";
111
static arg_t defn[] = {
115
"Shows the usage of the tool"},
120
"Shows example of how to use the tool"},
125
"The transition matrix parameter file name"},
130
"The mixture weight parameter file name"},
135
"Start id of mixing weight subinterval"},
140
"End id of mixing weight subinterval"},
145
"A Gaussian parameter file name (either for means or vars)"},
150
"A full Gaussian covariance file name"},
155
"A Gaussian parameter weighted vector file"},
160
"MLLR regression matrix count file"},
165
"An LDA transformation file name"},
170
"The model definition file"},
175
"The interpolation weight file"},
180
"Print int. wt. >= this"},
185
"Print int. wt. <= this"},
190
"The tied state to codebook mapping file"},
195
"Print normalized parameters"},
200
"Number of significant digits in 'e' notation" },
202
{NULL, 0, NULL, NULL},
205
cmd_ln_parse(defn, argc, argv, TRUE);
207
isHelp = cmd_ln_int32("-help");
208
isExample = cmd_ln_int32("-example");
211
printf("%s\n\n",helpstr);
215
printf("%s\n\n",examplestr);
218
if(isHelp || isExample){
219
E_INFO("User asked for help or example.\n");