~ubuntu-branches/ubuntu/jaunty/speech-tools/jaunty

« back to all changes in this revision

Viewing changes to include/EST_WFST.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Urlichs
  • Date: 2004-07-16 09:25:39 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040716092539-5p1tzif55b8j924e
Tags: 1:1.2.3-8
Added alaw processing code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
#include "EST_simplestats.h"
44
44
#include "EST_rw_status.h"
 
45
#include "EST_Option.h"
45
46
#include "EST_TList.h"
46
47
#include "EST_TVector.h"
47
 
#include "EST_StringTrie.h"
 
48
#include "EST_THash.h"
48
49
#include "siod.h"
49
50
#define wfst_error_msg(WMESS) (cerr << WMESS << endl,siod_error())
50
51
 
75
76
    int in_symbol() const { return p_in_symbol; }
76
77
    int out_symbol() const { return p_out_symbol; }
77
78
    void set_weight(float f) { p_weight = f; }
 
79
    void set_state(int s) { p_state = s; }
78
80
    
79
81
};
80
82
typedef EST_TList<EST_WFST_Transition *> wfst_translist;
81
83
 
82
84
enum wfst_state_type {wfst_final, wfst_nonfinal, wfst_error, wfst_licence};
 
85
/** I'd like to use the enums but I need to binary read/write them **/
 
86
/** I don't believe that's portable so we need to have ints for these **/
 
87
#define WFST_FINAL    0
 
88
#define WFST_NONFINAL 1
 
89
#define WFST_ERROR    2
 
90
#define WFST_LICENCE  3
 
91
 
83
92
 
84
93
/** an internal class for \Ref{EST_WFST} used to represent a 
85
94
    state in a WFST 
109
118
};
110
119
typedef EST_TVector<EST_WFST_State *> wfst_state_vector;
111
120
 
112
 
typedef EST_StringTrie EST_WFST_MultiStateIndex;
 
121
typedef EST_TStringHash<int> EST_WFST_MultiStateIndex;
113
122
enum wfst_mstate_type {wfst_ms_set, wfst_ms_list};
114
123
 
115
124
/** an internal class to \Ref{EST_WFST} used in holding multi-states
168
177
  public:
169
178
    /**@name Constructor and initialisation functions */
170
179
    //@{
 
180
    /// ?
171
181
    EST_WFST();
 
182
    /// ?
172
183
    EST_WFST(const EST_WFST &wfst) { p_num_states = 0; copy(wfst); }
173
184
    ~EST_WFST();
174
185
    //@}
209
220
    int out_epsilon() const { return p_out_symbols.name("__epsilon__"); }
210
221
    /// Return internal state information
211
222
    const EST_WFST_State *state(int i) const { return p_states(i); }
 
223
    /// Return internal state information (non-const)
 
224
    EST_WFST_State *state_non_const(int i) { return p_states(i); }
212
225
    /// True if state {\tt i} is final
213
226
    int final(int i) const 
214
227
       { return ((i != WFST_ERROR_STATE) && (state(i)->type() == wfst_final));}
 
228
    /// Accessing the input alphabet
 
229
    const EST_Discrete &in_symbols() const { return p_in_symbols; }
 
230
    /// Accessing the output alphabet
 
231
    const EST_Discrete &out_symbols() const { return p_out_symbols; }
215
232
 
216
233
    //@}
217
234
 
218
235
    /**@name file i/o */
219
236
    //@{
220
 
    EST_write_status save(const EST_String &filename);
 
237
    /// ?
 
238
    EST_write_status save(const EST_String &filename,
 
239
                          const EST_String type = "ascii");
 
240
    EST_write_status save_binary(FILE *fd);
 
241
    /// ?
221
242
    EST_read_status load(const EST_String &filename);
 
243
 
 
244
    EST_read_status load_binary(FILE *fd, 
 
245
                                EST_Option &hinfo, 
 
246
                                int num_states,
 
247
                                int swap);
222
248
    //@}
223
249
 
224
250
    /**@name transduction functions */
279
305
                       LISP distinguished, LISP rewrites,
280
306
                       LISP sets, LISP terms,
281
307
                       int max_depth);
 
308
    // Build simple tree lexicon
 
309
    void build_tree_lex(LISP inalpha, LISP outalpha, 
 
310
                         LISP wlist);
282
311
    //@}
283
312
 
284
313
    /**@name Basic WFST operators */
331
360
    void remove_error_states(const EST_WFST &a);
332
361
    
333
362
    EST_String summary() const;
334
 
    ///
 
363
    /// ?
335
364
    EST_WFST & operator = (const EST_WFST &a) { copy(a); return *this; }
336
365
};
337
366
typedef EST_TList<EST_WFST> wfst_list;
352
381
void ltscompile(LISP lts_rules, EST_WFST &all_wfst);
353
382
// Compile a regular grammar 
354
383
void rgcompile(LISP rg, EST_WFST &all_wfst);
 
384
// Compile a tree lexicon
 
385
void tlcompile(LISP rg, EST_WFST &all_wfst);
355
386
 
356
387
// Transduction and recognition functions
357
388
int transduce(const EST_WFST &wfst,const EST_StrList &in,EST_StrList &out);
359
390
int recognize(const EST_WFST &wfst,const EST_StrList &in,int quiet);
360
391
int recognize(const EST_WFST &wfst,const EST_IList &in, 
361
392
              const EST_IList &out,int quite);
 
393
int recognize_for_perplexity(const EST_WFST &wfst,
 
394
                             const EST_StrList &in,
 
395
                             int quiet,
 
396
                             float &count,
 
397
                             float &sumlogp);
 
398
int recognize_for_perplexity(const EST_WFST &wfst,
 
399
                             const EST_IList &in, 
 
400
                             const EST_IList &out, 
 
401
                             int quiet,
 
402
                             float &count,
 
403
                             float &sumlogp);
362
404
 
363
405
VAL_REGISTER_CLASS_DCLS(wfst,EST_WFST)
364
406