48#include "EST_cutils.h"
53static int production_index(
LISP state,
64 l_w = tl_find_l_w(rules);
77 for (r=rules; r != NIL; r=cdr(r))
79 for (s = car(r); s != NIL; s=cdr(s))
81 if (streq(
"->",get_c_string(car(s))))
83 if (!siod_member_str(get_c_string(car(cdr(s))),
words))
87 else if (!siod_member_str(get_c_string(car(s)),
letters))
115 p_start_state =
add_state(wfst_nonfinal);
118 for (w=
wlist; w; w=cdr(w))
121 weight = get_c_float(car(siod_last(car(w))));
122 for (
cs=p_start_state,l=car(w); l; l=cdr(l))
124 if (streq(
"->",get_c_string(car(l))))
128 p_out_symbols.
name(get_c_string(car(cdr(l)))));
132 ->add_transition(weight,
134 p_out_symbols.
name(get_c_string(car(cdr(l)))));
145 p_in_symbols.
name(get_c_string(car(l))),
149 ns = production_index(cdr(l),index,p_num_states);
150 if (
ns == p_num_states)
153 ->add_transition(weight,
155 p_in_symbols.
name(get_c_string(car(l))),
161 trans->set_weight(trans->weight()+weight);
172static int production_index(
LISP state,
184 for (p=state; p != NIL; p = cdr(p))
const EST_String & name(const int n) const
The name given the index.
int add_state(enum wfst_state_type state_type)
Add a new state, returns new name.
EST_WFST_Transition * find_transition(int state, int in, int out) const
Find (first) transition given in and out symbols.
void init(int init_num_states=10)
Clear with (estimation of number of states required)
void clear()
clear removing existing states if any
int out_epsilon() const
Internal index for output epsilon.
int in_epsilon() const
Internal index for input epsilon.
void stop_cumulate()
Stop cumulation and calculate probabilities on transitions.