44#include "EST_cutils.h"
49 return s <<
"<<EST_WFST>>";
54#if defined(INSTANTIATE_TEMPLATES)
55#include "../base_class/EST_TList.cc"
62static LISP find_feasible_pairs(
LISP rules);
83 fp = find_feasible_pairs(rules);
96 for (r=rules; r != NIL; r=cdr(r))
101 cout <<
"Rule: " << siod_llength(rules)-siod_llength(r) <<
endl;
120 cout <<
"intersecting " << i <<
" and " << i+1 <<
" " <<
125 cout <<
" " <<
mmm.summary() <<
" minimizes to " <<
endl;
128 nnp=p->next()->next();
145 for (s=
sets; s != NIL; s=cdr(s))
147 for (
ne=NIL,
e=cdr(car(s));
e != NIL;
e=cdr(
e))
150 if (
ss.contains(
"/"))
151 ne = cons(car(
e),
ne);
153 ne = append(expand_fp(
ss,fp),
ne);
157 cerr <<
"WFST: kkcompile: set " << get_c_string(car(car(s))) <<
158 " has no feasible pairs" <<
endl;
161 else if (siod_llength(
ne) == 1)
162 es = cons(cons(car(car(s)),
ne),
es);
164 es = cons(cons(car(car(s)),
165 cons(cons(rintern(
"or"),reverse(
ne)),
178 for (f=fp; f != NIL; f=cdr(f))
181 if ((p ==
ss) || (
ss.matches(
rg)))
187static LISP find_feasible_pairs(
LISP rules)
194 for (r=rules; r != NIL; r=cdr(r))
196 if (siod_member_str(get_c_string(siod_nth(0,car(r))),fp) == NIL)
197 fp = cons(siod_nth(0,car(r)),fp);
202static int surface_coercion(
LISP rt)
204 return (streq(
"<=",get_c_string(
rt)));
207static int context_restriction(
LISP rt)
209 return (streq(
"=>",get_c_string(
rt)));
212static int composite(
LISP rt)
214 return (streq(
"<=>",get_c_string(
rt)));
224 return cons(inline_sets(car(l),
sets),inline_sets(cdr(l),
sets));
225 else if ((s=siod_assoc_str(get_c_string(l),
sets)) != NIL)
249 for (p=fp; p != NIL; p=cdr(p))
252 build_wfst(p_start_state,p_start_state,car(p));
260 for (i=
end_LC; i < p_num_states; i++)
263 p_states[i]->set_type(wfst_final);
286 for (p=fp; p != NIL; p=cdr(p))
287 if (
transition(i,get_c_string(car(p))) == WFST_ERROR_STATE)
290 p_states[i]->set_type(wfst_licence);
315 p_states[i]->set_type(wfst_final);
346 for (r=fp; r != NIL; r = cdr(r))
348 rr = get_c_string(car(r));
349 if (
rr.contains(
"/"))
359 if ((l !=
lr) && (s ==
sr))
363 if (siod_llength(
notrp) > 1)
372 all.intersection(
wl);
EST_String before(int pos, int len=0) const
Part before position.
int contains(const char *s, int pos=-1) const
Does it contain this substring?
EST_String after(int pos, int len=1) const
Part after pos+len.
int add_state(enum wfst_state_type state_type)
Add a new state, returns new name.
void init(int init_num_states=10)
Clear with (estimation of number of states required)
void build_wfst(int start, int end, LISP regex)
Basic regex constructor.
LISP epsilon_label() const
LISP for on epsilon symbols.
int transition(int state, int in, int out) const
Find (first) new state given in and out symbols.