~ubuntu-branches/ubuntu/raring/sphinxtrain/raring-proposed

« back to all changes in this revision

Viewing changes to src/programs/printp/parse_cmd_ln.c

  • Committer: Package Import Robot
  • Author(s): Samuel Thibault
  • Date: 2013-01-02 04:10:21 UTC
  • Revision ID: package-import@ubuntu.com-20130102041021-ynsizmz33fx02hea
Tags: upstream-1.0.8
ImportĀ upstreamĀ versionĀ 1.0.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ====================================================================
 
2
 * Copyright (c) 1995-2000 Carnegie Mellon University.  All rights 
 
3
 * reserved.
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
8
 *
 
9
 * 1. Redistributions of source code must retain the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer. 
 
11
 *
 
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
 
15
 *    distribution.
 
16
 *
 
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.
 
20
 *
 
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.
 
32
 *
 
33
 * ====================================================================
 
34
 *
 
35
 */
 
36
/*********************************************************************
 
37
 *
 
38
 * File: parse_cmd_ln.c
 
39
 * 
 
40
 * Description: 
 
41
 * 
 
42
 * Author: 
 
43
 *      Eric H. Thayer (eht@cs.cmu.edu)
 
44
 *********************************************************************/
 
45
 
 
46
#include "parse_cmd_ln.h"
 
47
 
 
48
#include <s3/common.h>
 
49
#include <s3/s3.h>
 
50
 
 
51
#include <stdio.h>
 
52
#include <assert.h>
 
53
 
 
54
#include <sys/stat.h>
 
55
#include <sys/types.h>
 
56
 
 
57
/* defines, parses and (partially) validates the arguments
 
58
   given on the command line */
 
59
 
 
60
int
 
61
parse_cmd_ln(int argc, char *argv[])
 
62
{
 
63
  uint32      isHelp;
 
64
  uint32      isExample;
 
65
 
 
66
    const char helpstr[] =  
 
67
"Description: \n\
 
68
\n\
 
69
Display numerical values of resources generated by Sphinx \n\
 
70
Current we supoort the following formats \n\
 
71
\n\
 
72
-tmatfn : transition matrix \n\
 
73
\n\
 
74
-mixwfn : mixture weight file  \n\
 
75
\n\
 
76
-gaufn  : mean or variance \n\
 
77
\n\
 
78
-fullgaufn  : full covariance \n\
 
79
\n\
 
80
-gaucntn : sufficient statistics for mean and diagonal covariance \n\
 
81
\n\
 
82
-lambdafn : interpolation weight \n\
 
83
\n\
 
84
Currently, some parameters can be specified as intervals such as mixture weight.  \n\
 
85
\n\
 
86
You can also specified -sigfig the number of significant digits by you would like to see. \n\
 
87
\n\
 
88
and normalize the parameters by -norm";
 
89
 
 
90
    const char examplestr[] = 
 
91
"Example: \n\
 
92
\n\
 
93
Print the mean of a Gaussian: \n\
 
94
printp -gaufn mean \n\
 
95
\n\
 
96
Print the variance of a Gaussian: \n\
 
97
printp -gaufn var \n\
 
98
\n\
 
99
Print the sufficient statistic: \n\
 
100
printp -gaucntfn gaucnt: \n\
 
101
\n\
 
102
Print the mixture weights: \n\
 
103
printp -mixw mixw\n\
 
104
\n\
 
105
Print the LDA transformation matrix(es): \n\
 
106
printp -lda lda\n\
 
107
\n\
 
108
Print the interpolation weight: \n\
 
109
printp -lambdafn lambda ";
 
110
 
 
111
    static arg_t defn[] = {
 
112
        { "-help",
 
113
          ARG_BOOLEAN,
 
114
          "no",
 
115
          "Shows the usage of the tool"},
 
116
 
 
117
        { "-example",
 
118
          ARG_BOOLEAN,
 
119
          "no",
 
120
          "Shows example of how to use the tool"},
 
121
 
 
122
        { "-tmatfn",
 
123
          ARG_STRING,
 
124
          NULL,
 
125
          "The transition matrix parameter file name"},
 
126
 
 
127
        { "-mixwfn",
 
128
          ARG_STRING,
 
129
          NULL,
 
130
          "The mixture weight parameter file name"},
 
131
 
 
132
        { "-mixws",
 
133
          ARG_INT32,
 
134
          NULL,
 
135
          "Start id of mixing weight subinterval"},
 
136
 
 
137
        { "-mixwe",
 
138
          ARG_INT32,
 
139
          NULL,
 
140
          "End id of mixing weight subinterval"},
 
141
 
 
142
        { "-gaufn",
 
143
          ARG_STRING,
 
144
          NULL,
 
145
          "A Gaussian parameter file name (either for means or vars)"},
 
146
 
 
147
        { "-fullgaufn",
 
148
          ARG_STRING,
 
149
          NULL,
 
150
          "A full Gaussian covariance file name"},
 
151
 
 
152
        { "-gaucntfn",
 
153
          ARG_STRING,
 
154
          NULL,
 
155
          "A Gaussian parameter weighted vector file"},
 
156
 
 
157
        { "-regmatcntfn",
 
158
          ARG_STRING,
 
159
          NULL,
 
160
          "MLLR regression matrix count file"},
 
161
 
 
162
        { "-lda",
 
163
          ARG_STRING,
 
164
          NULL,
 
165
          "An LDA transformation file name"},
 
166
 
 
167
        { "-moddeffn",
 
168
          ARG_STRING,
 
169
          NULL,
 
170
          "The model definition file"},
 
171
 
 
172
        { "-lambdafn",
 
173
          ARG_STRING,
 
174
          NULL,
 
175
          "The interpolation weight file"},
 
176
 
 
177
        { "-lambdamin",
 
178
          ARG_FLOAT32,
 
179
          "0",
 
180
          "Print int. wt. >= this"},
 
181
 
 
182
        { "-lambdamax",
 
183
          ARG_FLOAT32,
 
184
          "1",
 
185
          "Print int. wt. <= this"},
 
186
 
 
187
        { "-ts2cbfn",
 
188
          ARG_STRING,
 
189
          NULL,
 
190
          "The tied state to codebook mapping file"},
 
191
 
 
192
        { "-norm",
 
193
          ARG_BOOLEAN,
 
194
          "yes",
 
195
          "Print normalized parameters"},
 
196
 
 
197
        { "-sigfig",
 
198
          ARG_INT32,
 
199
          "4",
 
200
          "Number of significant digits in 'e' notation" },
 
201
 
 
202
        {NULL, 0, NULL, NULL},
 
203
    };
 
204
 
 
205
    cmd_ln_parse(defn, argc, argv, TRUE);
 
206
 
 
207
    isHelp    = cmd_ln_int32("-help");
 
208
    isExample    = cmd_ln_int32("-example");
 
209
 
 
210
    if(isHelp){
 
211
      printf("%s\n\n",helpstr);
 
212
    }
 
213
 
 
214
    if(isExample){
 
215
      printf("%s\n\n",examplestr);
 
216
    }
 
217
 
 
218
    if(isHelp || isExample){
 
219
      E_INFO("User asked for help or example.\n");
 
220
      exit(0);
 
221
    }
 
222
 
 
223
    return 0;
 
224
}