40 #ifndef __EST_WFST_H__ 41 #define __EST_WFST_H__ 50 #define wfst_error_msg(WMESS) (std::cerr << WMESS << std::endl,siod_error()) 52 #define WFST_ERROR_STATE -1 70 { p_weight=t.p_weight; p_state=t.p_state;
71 p_in_symbol = t.p_in_symbol; p_out_symbol=t.p_out_symbol; }
73 { p_weight=w; p_state=s; p_in_symbol=i; p_out_symbol=o;}
75 float weight()
const {
return p_weight; }
76 int state()
const {
return p_state; }
89 #define WFST_NONFINAL 1 91 #define WFST_LICENCE 3 114 int name()
const {
return p_name; }
119 int tag()
const {
return p_tag;}
137 { p_name = -1; p_weight = 0.0; p_type =
wfst_ms_set; }
139 { p_name = -1; p_weight = 0.0; p_type = ty; }
140 int name()
const {
return p_name; }
142 float weight()
const {
return p_weight; }
164 int operator_and(LISP l);
165 int operator_or(LISP l);
166 int operator_star(LISP l);
167 int operator_plus(LISP l);
168 int operator_optional(LISP l);
169 int operator_not(LISP l);
170 int terminal(LISP l);
174 void extend_alphabets(
const EST_WFST &b);
177 void more_states(
int new_max);
179 int can_reach_final(
int state);
180 static int traverse_tag;
194 void init(
int init_num_states=10);
196 void init(LISP in, LISP out);
209 {
return p_in_symbols.
name(s); }
212 {
return p_in_symbols.
name(i); }
215 {
return p_out_symbols.
name(s); }
218 {
return p_out_symbols.
name(i); }
230 int final(
int i)
const 257 int transition(
int state,
int in,
int out)
const;
258 int transition(
int state,
int in,
int out,
float &prob)
const;
264 int transition(
int state,
const EST_String &inout)
const;
266 int transduce(
int state,
int in,
int &out)
const;
272 void transition_all(
int state,
int in,
int out,
283 void start_cumulate();
285 void stop_cumulate();
296 void build_wfst(
int start,
int end,LISP regex);
298 void build_and_transition(
int start,
int end, LISP conjunctions);
300 void build_or_transition(
int start,
int end, LISP disjunctions);
303 void build_from_regex(LISP inalpha, LISP outalpha, LISP regex);
305 void kkrule_compile(LISP inalpha, LISP outalpha, LISP
fp,
306 LISP rule, LISP sets);
308 void build_from_rg(LISP inalpha, LISP outalpha,
309 LISP distinguished, LISP rewrites,
310 LISP sets, LISP terms,
313 void build_tree_lex(LISP inalpha, LISP outalpha,
356 int deterministic()
const;
360 int in,
int out)
const;
364 void remove_error_states(
const EST_WFST &a);
EST_TVector< EST_WFST_State * > wfst_state_vector
LISP epsilon_label() const
LISP for on epsilon symbols.
float end(const EST_Item &item)
int multistate_index(EST_WFST_MultiStateIndex &i, EST_WFST_MultiState *ms)
void ltscompile(LISP lts_rules, EST_WFST &all_wfst)
void rgcompile(LISP rg, EST_WFST &all_wfst)
EST_WFST_MultiState(enum wfst_mstate_type ty)
an internal class for EST_WFST for representing transitions in an WFST
void difference(EST_WFST &a, EST_WFST &b, EST_WFST &c)
a call representing a weighted finite-state transducer
EST_TList< EST_WFST_Transition * > wfst_translist
EST_WFST(const EST_WFST &wfst)
?
bool save(Lattice &lattice, EST_String filename)
int out_epsilon() const
Internal index for output epsilon.
const EST_String & name(const int n) const
The name given the index.
EST_TList< EST_WFST > wfst_list
int transduce(const EST_WFST &wfst, const EST_StrList &in, EST_StrList &out)
bool load(Lattice &lattice, EST_String filename)
void determinize(EST_WFST &a, EST_WFST &b)
A specialised hash table for when the key is an EST_String.
EST_WFST_Transition(float w, int s, int i, int o)
void kkcompile(LISP ruleset, EST_WFST &all_wfst)
void intersect(wfst_list &wl, EST_WFST &wfst)
int in_symbol(const EST_String &s) const
Map input symbol to input alphabet index.
EST_TStringHash< int > EST_WFST_MultiStateIndex
const EST_Discrete & out_symbols() const
Accessing the output alphabet.
int cumulate() const
Cumulation condition.
an internal class to EST_WFST used in holding multi-states when determinizing and find the intersecti...
int recognize(const EST_WFST &wfst, const EST_StrList &in, int quiet)
void complement(EST_WFST &a, EST_WFST &b)
const EST_Discrete & in_symbols() const
Accessing the input alphabet.
EST_FVector add(const EST_FVector &a, const EST_FVector &b)
elementwise add
#define VAL_REGISTER_CLASS_DCLS(NAME, CLASS)
an internal class for EST_WFST used to represent a state in a WFST
void concat(EST_WFST &a, EST_WFST &b, EST_WFST &c)
int out_symbol(const EST_String &s) const
Map output symbol to output alphabet index.
const EST_WFST_State * state(int i) const
Return internal state information.
const EST_String & in_symbol(int i) const
Map input alphabet index to input symbol.
EST_TVector< T > & copy(EST_TVector< T > a, const EST_TList< T > &in)
void set_type(wfst_state_type t)
void tlcompile(LISP rg, EST_WFST &all_wfst)
void minimize(EST_WFST &a, EST_WFST &b)
float start(const EST_Item &item)
int in_epsilon() const
Internal index for input epsilon.
LISP rintern(const char *name)
EST_WFST_State * state_non_const(int i)
Return internal state information (non-const)
void compose(EST_WFST &a, EST_WFST &b, EST_WFST &c)
void set_type(enum wfst_mstate_type s)
EST_WFST_Transition(const EST_WFST_Transition &t)
void concatenate(EST_WFST &a, EST_WFST &b, EST_WFST &c)
const EST_String & out_symbol(int i) const
Map output alphabet index to output symbol.
wfst_translist transitions
int recognize_for_perplexity(const EST_WFST &wfst, const EST_StrList &in, int quiet, float &count, float &sumlogp)
int num_transitions() const