~ubuntu-branches/ubuntu/saucy/sphinxtrain/saucy

« back to all changes in this revision

Viewing changes to src/programs/inc_comp/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) 1994-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
 *      This file contains the code to define and parse the command
 
42
 *      line for the inc_comp command.
 
43
 *
 
44
 * Author: 
 
45
 *      Eric H. Thayer (eht@cs.cmu.edu)
 
46
 *********************************************************************/
 
47
 
 
48
#include "parse_cmd_ln.h"
 
49
 
 
50
#include <stdio.h>
 
51
#include <stdlib.h>
 
52
#include <sphinxbase/cmd_ln.h>
 
53
#include <sphinxbase/err.h>
 
54
 
 
55
int
 
56
parse_cmd_ln(int argc, char *argv[])
 
57
{
 
58
  uint32      isHelp;
 
59
  uint32      isExample;
 
60
 
 
61
  const char helpstr[] = 
 
62
"Description: \n\
 
63
\n\
 
64
Increase the number of mixture of a continuous HMM.  Notice that option \n\
 
65
-ninc actually means the number of mixture one wants to split from the \n\
 
66
 original models. For example, if you have already 8 mixture and you \n\
 
67
 want to go to 16, then 8 should be specified.  \n\
 
68
\n\
 
69
Usually, the number of mixture is a power of two.  You are also \n\
 
70
recommended to split the number of mixture from 1 -> 2 -> 4 -> 8 \n\
 
71
-> and so on. \n\
 
72
";
 
73
 
 
74
 
 
75
  const char examplestr[] = 
 
76
"Example : \n\
 
77
\n\
 
78
inc_comp \n\
 
79
 -ninc 16 \n\
 
80
 -dcountfn mixture_weights \n\
 
81
 -inmixwfn mixture_weights \n\
 
82
 -outmixwfn out_mixture_weights \n\
 
83
 -inmeanfn means \n\
 
84
 -outmeanfn out_means \n\
 
85
 -invarfn variance \n\
 
86
 -outvarfn out_variance";
 
87
 
 
88
    static arg_t defn[] = {
 
89
        { "-help",
 
90
          ARG_BOOLEAN,
 
91
          "no",
 
92
          "Shows the usage of the tool"},
 
93
 
 
94
        { "-example",
 
95
          ARG_BOOLEAN,
 
96
          "no",
 
97
          "Shows example of how to use the tool"},
 
98
 
 
99
        { "-ninc",
 
100
          ARG_INT32,
 
101
          "1",
 
102
          "The # of densities to split"},
 
103
 
 
104
        { "-inmixwfn",
 
105
          ARG_STRING,
 
106
          NULL,
 
107
          "The weight file for all N den/mix"},
 
108
 
 
109
        { "-outmixwfn",
 
110
          ARG_STRING,
 
111
          NULL,
 
112
          "The output mixing weight file name w/ N+NINC density weights/mixture"},
 
113
 
 
114
        { "-inmeanfn",
 
115
          ARG_STRING,
 
116
          NULL,
 
117
          "The source mean file w/ N means"},
 
118
 
 
119
        { "-outmeanfn",
 
120
          ARG_STRING,
 
121
          NULL,
 
122
          "The new mean file w/ N+NINC means"},
 
123
 
 
124
        { "-invarfn",
 
125
          ARG_STRING,
 
126
          NULL,
 
127
          "The source variance file w/ N means"},
 
128
 
 
129
        { "-fullvar",
 
130
          ARG_BOOLEAN,
 
131
          "no",
 
132
          "variances file contains full covariances" },
 
133
 
 
134
        { "-outvarfn",
 
135
          ARG_STRING,
 
136
          NULL,
 
137
          "The new variance file w/ N+NINC means"},
 
138
 
 
139
        { "-dcountfn",
 
140
          ARG_STRING,
 
141
          NULL,
 
142
          "The density counts for the N source den/mix"},
 
143
 
 
144
        {NULL, 0, NULL, NULL}
 
145
    };
 
146
 
 
147
    cmd_ln_parse(defn, argc, argv, 1);
 
148
 
 
149
    isHelp    = cmd_ln_int32("-help");
 
150
    isExample    = cmd_ln_int32("-example");
 
151
 
 
152
    if(isHelp){
 
153
      printf("%s\n\n",helpstr);
 
154
    }
 
155
 
 
156
    if(isExample){
 
157
      printf("%s\n\n",examplestr);
 
158
    }
 
159
 
 
160
    if(isHelp || isExample){
 
161
      E_INFO("User asked for help or example.\n");
 
162
      exit(0);
 
163
    }
 
164
 
 
165
 
 
166
    return 0;
 
167
}
 
168