47#ifndef __FSG_MODEL_H__
48#define __FSG_MODEL_H__
61#include <sphinxbase/sphinxbase_export.h>
82#define fsg_link_from_state(l) ((l)->from_state)
83#define fsg_link_to_state(l) ((l)->to_state)
84#define fsg_link_wid(l) ((l)->wid)
85#define fsg_link_logs2prob(l) ((l)->logs2prob)
118#define fsg_model_name(f) ((f)->name)
119#define fsg_model_n_state(f) ((f)->n_state)
120#define fsg_model_start_state(f) ((f)->start_state)
121#define fsg_model_final_state(f) ((f)->final_state)
122#define fsg_model_log(f,p) logmath_log((f)->lmath, p)
123#define fsg_model_lw(f) ((f)->lw)
124#define fsg_model_n_word(f) ((f)->n_word)
125#define fsg_model_word_str(f,wid) (wid == -1 ? "(NULL)" : (f)->vocab[wid])
135#define fsg_model_has_sil(f) ((f)->silwords != NULL)
140#define fsg_model_has_alt(f) ((f)->altwords != NULL)
142#define fsg_model_is_filler(f,wid) \
143 (fsg_model_has_sil(f) ? bitvec_is_set((f)->silwords, wid) : FALSE)
144#define fsg_model_is_alt(f,wid) \
145 (fsg_model_has_alt(f) ? bitvec_is_set((f)->altwords, wid) : FALSE)
151fsg_model_t *fsg_model_init(
char const *name,
logmath_t *lmath,
152 float32 lw, int32 n_state);
194fsg_model_t *fsg_model_readfile(
const char *file,
logmath_t *lmath, float32 lw);
200fsg_model_t *fsg_model_read(FILE *fp,
logmath_t *lmath, float32 lw);
208fsg_model_t *fsg_model_retain(fsg_model_t *fsg);
216int fsg_model_free(fsg_model_t *fsg);
224int fsg_model_word_add(fsg_model_t *fsg,
char const *word);
232int fsg_model_word_id(fsg_model_t *fsg,
char const *word);
241void fsg_model_trans_add(fsg_model_t * fsg,
242 int32 from, int32 to, int32 logp, int32 wid);
255int32 fsg_model_null_trans_add(fsg_model_t * fsg, int32 from, int32 to, int32 logp);
272int32 fsg_model_tag_trans_add(fsg_model_t * fsg, int32 from, int32 to,
273 int32 logp, int32 wid);
282glist_t fsg_model_null_trans_closure(fsg_model_t * fsg, glist_t nulls);
288glist_t fsg_model_trans(fsg_model_t *fsg, int32 i, int32 j);
294fsg_arciter_t *fsg_model_arcs(fsg_model_t *fsg, int32 i);
300fsg_link_t *fsg_arciter_get(fsg_arciter_t *itor);
306fsg_arciter_t *fsg_arciter_next(fsg_arciter_t *itor);
312void fsg_arciter_free(fsg_arciter_t *itor);
317fsg_link_t *fsg_model_null_trans(fsg_model_t *fsg, int32 i, int32 j);
326int fsg_model_add_silence(fsg_model_t * fsg,
char const *silword,
327 int state, float32 silprob);
333int fsg_model_add_alt(fsg_model_t * fsg,
char const *baseword,
334 char const *altword);
340void fsg_model_write(fsg_model_t *fsg, FILE *fp);
346void fsg_model_writefile(fsg_model_t *fsg,
char const *file);
352void fsg_model_write_fsm(fsg_model_t *fsg, FILE *fp);
358void fsg_model_writefile_fsm(fsg_model_t *fsg,
char const *file);
364void fsg_model_write_symtab(fsg_model_t *fsg, FILE *file);
370void fsg_model_writefile_symtab(fsg_model_t *fsg,
char const *file);
An implementation of bit vectors.
Generic linked-lists maintenance.
Hash table implementation.
Fast memory allocator for uniformly sized objects.
struct listelem_alloc_s listelem_alloc_t
List element allocator object.
Fast integer logarithmic addition operations.
struct logmath_s logmath_t
Integer log math computation class.
Basic type definitions used in Sphinx.
Implementation of arc iterator.
int32 logs2prob
log(transition probability)*lw
int32 wid
Word-ID; <0 if epsilon or null transition.
Word level FSG definition.
int32 n_word_alloc
Number of words allocated in vocab.
int32 start_state
Must be in the range [0..n_state-1].
char ** vocab
Vocabulary for this FSG.
int32 n_state
number of states in FSG
int32 n_word
Number of unique words in this FSG.
logmath_t * lmath
Pointer to log math computation object.
char * name
A unique string identifier for this FSG.
bitvec_t * silwords
Indicates which words are silence/fillers.
listelem_alloc_t * link_alloc
Allocator for FSG links.
trans_list_t * trans
Transitions out of each state, if any.
int32 final_state
Must be in the range [0..n_state-1].
bitvec_t * altwords
Indicates which words are pronunciation alternates.
float32 lw
Language weight that's been applied to transition logprobs.
int refcount
Reference count.
Adjacency list (opaque) for a state in an FSG.