~ubuntu-branches/ubuntu/maverick/speech-tools/maverick

« back to all changes in this revision

Viewing changes to main/wagon_main.cc

  • Committer: Bazaar Package Importer
  • Author(s): Kumar Appaiah, Kartik Mistry, Kumar Appaiah
  • Date: 2010-07-17 11:32:04 UTC
  • mfrom: (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100717113204-mnse3jo236j107q8
Tags: 1:2.0.95~beta-1
[ Kartik Mistry ]
* debian/control:
  + [Lintian] Added missing ${misc:Depends}
  + Updated Standards-Version to 3.8.4 (no changes needed)
* debian/patches/const_char.diff:
  + Added missing patch header
* Removed unused patch invalid_const_char_conversion_fixes.diff

[ Kumar Appaiah ]
* New upstream release.
* Standards Version is now 3.9.0 (No changes needed)
* Update debian/rules to specify version numbers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/*                                                                       */
3
3
/*                Centre for Speech Technology Research                  */
4
4
/*                     University of Edinburgh, UK                       */
5
 
/*                     Copyright (c) 1996-2005                           */
 
5
/*                     Copyright (c) 1996-2006                           */
6
6
/*                        All Rights Reserved.                           */
7
7
/*                                                                       */
8
8
/*  Permission is hereby granted, free of charge, to use and distribute  */
39
39
/*                                                                       */
40
40
/*  Added decision list support, Feb 1997                                */
41
41
/*                                                                       */
 
42
/*  Added vector support for Clustergen 2005/2006                        */
 
43
/*                                                                       */
42
44
/*=======================================================================*/
43
45
#include <cstdlib>
44
46
#include <iostream>
111
113
    return 0;
112
114
}
113
115
 
 
116
static int set_Vertex_Feats(EST_Track &wgn_VertexFeats,
 
117
                            EST_String &wagon_track_features)
 
118
{
 
119
    int i,s=0,e;
 
120
    EST_TokenStream ts;
 
121
 
 
122
    for (i=0; i<wgn_VertexFeats.num_channels(); i++)
 
123
        wgn_VertexFeats.a(0,i) = 0.0;
 
124
 
 
125
    ts.open_string(wagon_track_features);
 
126
    ts.set_WhiteSpaceChars(",- ");
 
127
    ts.set_PunctuationSymbols("");
 
128
    ts.set_PrePunctuationSymbols("");
 
129
    ts.set_SingleCharSymbols("");
 
130
 
 
131
    while (!ts.eof())
 
132
    {
 
133
        EST_Token &token = ts.get();
 
134
        const EST_String ws = (const char *)token.whitespace();
 
135
        if (token == "all")
 
136
        {
 
137
            for (i=0; i<wgn_VertexFeats.num_channels(); i++)
 
138
                wgn_VertexFeats.a(0,i) = 1.0;
 
139
            break;
 
140
        } else if ((ws == ",") || (ws == ""))
 
141
        {
 
142
            s = atoi(token.string());
 
143
            wgn_VertexFeats.a(0,s) = 1.0;
 
144
        } else if (ws == "-")
 
145
        {
 
146
            if (token == "")
 
147
                e = wgn_VertexFeats.num_channels()-1;
 
148
            else
 
149
                e = atoi(token.string());
 
150
            for (i=s; i<=e && i<wgn_VertexFeats.num_channels(); i++)
 
151
                wgn_VertexFeats.a(0,i) = 1.0;
 
152
        } else
 
153
        {
 
154
            printf("wagon: track_feats invalid: %s at position %d\n",
 
155
                   (const char *)wagon_track_features,
 
156
                   ts.filepos());
 
157
            exit(-1);
 
158
        }
 
159
    }
 
160
 
 
161
    return 0;
 
162
}
 
163
 
114
164
static int wagon_main(int argc, char **argv)
115
165
{
116
166
    // Top level function sets up data and creates a tree
119
169
    EST_String wgn_oname;
120
170
    ostream *wgn_coutput = 0;
121
171
    float stepwise_limit = 0;
 
172
    int feats_start=0, feats_end=0;
 
173
    int i;
122
174
 
123
175
    parse_command_line
124
176
        (argc, argv,
142
194
         "                  start channel vertex indices\n"+
143
195
         "-track_end <int>\n"+
144
196
         "                  end (inclusive) channel for vertex indices\n"+
 
197
         "-track_feats <string>\n"+
 
198
         "                  Track features to use, comma separated list\n"+
 
199
         "                  with feature numbers and/or ranges, 0 start\n"+
145
200
         "-unittrack <ifile>\n"+
146
201
         "                  track for unit start and length in vertex track\n"+
147
202
         "-quiet            No questions printed during building\n"+
154
209
         "                  Name of field containing count weight for samples\n"+
155
210
         "-stepwise         Incrementally find best features\n"+
156
211
         "-swlimit <float> {0.0}\n"+
157
 
         "                  Percentage necessary improvement for stepwise\n"+
 
212
         "                  Percentage necessary improvement for stepwise,\n"+
 
213
         "                  may be negative.\n"+
158
214
         "-swopt <string>   Parameter to optimize for stepwise, for \n"+
159
215
         "                  classification options are correct or entropy\n"+
160
216
         "                  for regression options are rmse or correlation\n"+
256
312
    else if (al.present("-track"))
257
313
    {
258
314
        wgn_VertexTrack.load(al.val("-track"));
259
 
        wgn_VertexTrack_start = 0;
260
 
        wgn_VertexTrack_end = wgn_VertexTrack.num_channels()-1;
 
315
        wgn_VertexFeats.resize(1,wgn_VertexTrack.num_channels());
 
316
        for (i=0; i<wgn_VertexFeats.num_channels(); i++)
 
317
            wgn_VertexFeats.a(0,i) = 1.0;
261
318
    }
262
319
 
263
320
    if (al.present("-track_start"))
264
321
    {
265
 
        wgn_VertexTrack_start = al.ival("-track_start");
266
 
        if ((wgn_VertexTrack_start < 0) ||
267
 
            (wgn_VertexTrack_start > wgn_VertexTrack.num_channels()))
 
322
        feats_start = al.ival("-track_start");
 
323
        if ((feats_start < 0) ||
 
324
            (feats_start > wgn_VertexTrack.num_channels()))
268
325
        {
269
326
            printf("wagon: track_start invalid: %d out of %d channels\n",
270
 
                   wgn_VertexTrack_start,
 
327
                   feats_start,
271
328
                   wgn_VertexTrack.num_channels());
272
329
            exit(-1);
273
330
        }
 
331
        for (i=0; i<feats_start; i++)
 
332
            wgn_VertexFeats.a(0,i) = 0.0; /* don't do feats up to start */
 
333
            
274
334
    }
275
335
 
276
336
    if (al.present("-track_end"))
277
337
    {
278
 
        wgn_VertexTrack_end = al.ival("-track_end");
279
 
        if ((wgn_VertexTrack_end < wgn_VertexTrack_start) ||
280
 
            (wgn_VertexTrack_end > wgn_VertexTrack.num_channels()))
 
338
        feats_end = al.ival("-track_end");
 
339
        if ((feats_end < feats_start) ||
 
340
            (feats_end > wgn_VertexTrack.num_channels()))
281
341
        {
282
342
            printf("wagon: track_end invalid: %d between start %d out of %d channels\n",
283
 
                   wgn_VertexTrack_end,
284
 
                   wgn_VertexTrack_start,
 
343
                   feats_end,
 
344
                   feats_start,
285
345
                   wgn_VertexTrack.num_channels());
286
346
            exit(-1);
287
347
        }
288
 
    }
 
348
        for (i=feats_end+1; i<wgn_VertexTrack.num_channels(); i++)
 
349
            wgn_VertexFeats.a(0,i) = 0.0; /* don't do feats after end */
 
350
    }
 
351
    if (al.present("-track_feats"))
 
352
    {   /* overrides start and end numbers */
 
353
        EST_String wagon_track_features = al.val("-track_feats");
 
354
        set_Vertex_Feats(wgn_VertexFeats,wagon_track_features);
 
355
    }
 
356
 
 
357
    //    printf("Track feats\n");
 
358
    //    for (i=0; i<wgn_VertexTrack.num_channels(); i++)
 
359
    //        if (wgn_VertexFeats.a(0,i) > 0.0)
 
360
    //            printf("%d ",i);
 
361
    //    printf("\n");
289
362
 
290
363
    if (al.present("-unittrack"))
291
364
    {   /* contains two features, a start and length.  start indexes */