58 return s <<
"<<wfst_tstate>>";
63 #if defined(INSTANTIATE_TEMPLATES) 64 #include "../base_class/EST_TList.cc" 72 static void add_transduce_mstate(
const EST_WFST &wfst,
73 const wfst_tstate &cs,
75 wfst_tstate_list &ns);
84 for (p=in.
head(); p != 0; p=p->
next())
89 for (p=out_i.
head(); p != 0; p=p->
next())
100 wfst_tstate_list *current_ms =
new wfst_tstate_list;
101 wfst_tstate start_state;
105 start_state.score = 0;
106 current_ms->append(start_state);
109 add_transduce_mstate(wfst,start_state,ss_eps_trans,*current_ms);
111 for (i=in.
head(); i != 0; i=i->
next())
113 wfst_tstate_list *ns =
new wfst_tstate_list;
115 for (cs=current_ms->head(); cs != 0; cs=cs->
next())
118 wfst.
transduce((*current_ms)(cs).state,in(i),translist);
119 add_transduce_mstate(wfst,(*current_ms)(cs),translist,*ns);
125 if (current_ms->length() == 0)
129 if (current_ms->length() > 1)
130 cerr <<
"WFST: found " << current_ms->length() <<
" transductions" <<
134 for (cs = current_ms->head(); cs != 0; cs=cs->
next())
136 if ((wfst.
final((*current_ms)(cs).state)) &&
137 ((*current_ms)(cs).outs.length() > out.
length()))
140 out = (*current_ms)(cs).outs;
147 static void add_transduce_mstate(
const EST_WFST &wfst,
148 const wfst_tstate &cs,
150 wfst_tstate_list &ns)
160 for (t=translist.
head(); t != 0; t=t->
next())
166 wfst_tstate &ts = ns.last();
168 ts.state = translist(t)->state();
170 ts.score = translist(t)->weight()+cs.score;
173 ts.outs.append(translist(t)->out_symbol());
178 add_transduce_mstate(wfst,ts,etranslist,ns);
190 for (p=in.
head(); p != 0; p=p->
next())
192 if (in(p).contains(
"/"))
219 ((p != 0) && (q != 0));
224 printf(
"state %d %s/%s -> %d\n",state,
235 cerr <<
"wfst recognize: in/out tapes of different lengths" 240 if (wfst.
final(state))
258 for (p=in.
head(); p != 0; p=p->
next())
260 if (in(p).contains(
"/"))
294 ((p != 0) && (q != 0));
297 nstate = wfst.
transition(state,in(p),out(q),prob);
300 sumlogp += log(prob);
304 printf(
"state %d %s/%s -> %d\n",state,
315 cerr <<
"wfst recognize: in/out tapes of different lengths" 320 if (wfst.
final(state))
int transduce(const EST_WFST &wfst, const EST_StrList &in, EST_StrList &out)
int transition(int state, int in, int out) const
Find (first) new state given in and out symbols.
int transduce(int state, int in, int &out) const
Transduce in to out from state.
ostream & operator<<(ostream &s, const wfst_tstate &state)
a call representing a weighted finite-state transducer
#define Instantiate_TList(TYPE)
int final(int i) const
True if state i is final.
Declare_TList(wfst_tstate) typedef EST_TList< wfst_tstate > wfst_tstate_list
int in_symbol(const EST_String &s) const
Map input symbol to input alphabet index.
int recognize(const EST_WFST &wfst, const EST_StrList &in, int quiet)
int out_symbol(const EST_String &s) const
Map output symbol to output alphabet index.
void append(const T &item)
add item onto end of list
int in_epsilon() const
Internal index for input epsilon.
int recognize_for_perplexity(const EST_WFST &wfst, const EST_StrList &in, int quiet, float &count, float &sumlogp)