51 return s <<
"<<EST_WFST>>";
56 #if defined(INSTANTIATE_TEMPLATES) 57 #include "../base_class/EST_TList.cc" 64 static LISP find_feasible_pairs(LISP rules);
65 static LISP all_but(LISP rulepair,LISP
fp);
66 static LISP expand_sets(LISP sets,LISP
fp);
67 static LISP inline_sets(LISP l, LISP sets);
68 static void full_kkcompile(LISP inalpha,LISP outalpha,
69 LISP
fp, LISP rules, LISP sets,
85 fp = find_feasible_pairs(rules);
86 sets = expand_sets(sets,fp);
88 full_kkcompile(inalpha,outalpha,fp,rules,sets,all_wfst);
91 static void full_kkcompile(LISP inalpha,LISP outalpha,
92 LISP
fp, LISP rules, LISP sets,
98 for (r=rules; r !=
NIL; r=
cdr(r))
106 cout <<
" base " << base_wfst.
summary() << endl;
108 cout <<
" determinized " << det_wfst.
summary() << endl;
110 cout <<
" minimized " << rr_wfst.
summary() << endl;
113 cout <<
"WFST: intersecting " << rulelist.
length() <<
" rules" << endl;
116 for (i=0,p=rulelist.
head(); p->
next() != 0; p=nnp)
122 cout <<
"intersecting " << i <<
" and " << i+1 <<
" " <<
123 rulelist.
length()-2 <<
" left" << endl;
124 cout <<
" " << rulelist(p).summary() <<
" and " << endl;
125 cout <<
" " << rulelist(p->
next()).summary() <<
" becomes " << endl;
127 cout <<
" " << mmm.
summary() <<
" minimizes to " << endl;
129 cout <<
" " << rr_wfst.
summary() << endl;
136 all_wfst = rulelist.
first();
140 static LISP expand_sets(LISP sets,LISP
fp)
147 for (s=sets; s !=
NIL; s=
cdr(s))
155 ne =
append(expand_fp(ss,fp),ne);
160 " has no feasible pairs" << endl;
180 for (f=fp; f !=
NIL; f=
cdr(f))
183 if ((p == ss) || (ss.
matches(rg)))
189 static LISP find_feasible_pairs(LISP rules)
196 for (r=rules; r !=
NIL; r=
cdr(r))
204 static int surface_coercion(LISP rt)
209 static int context_restriction(LISP rt)
214 static int composite(LISP rt)
219 static LISP inline_sets(LISP l, LISP sets)
226 return cons(inline_sets(
car(l),sets),inline_sets(
cdr(l),sets));
238 LISP leftcontext = inline_sets(
siod_nth(2,rule),sets);
241 LISP rightcontext = inline_sets(
siod_nth(4,rule),sets);
244 int end_LC,end_RP,end_NOTRP,end_RC,err_state;
247 init(inalpha,outalpha);
251 for (p=fp; p !=
NIL; p=
cdr(p))
253 (surface_coercion(ruletype)))
254 build_wfst(p_start_state,p_start_state,
car(p));
260 build_wfst(p_start_state,end_LC,leftcontext);
262 for (i=end_LC; i < p_num_states; i++)
264 build_wfst(i,p_start_state,epsilon_label());
269 end_LC = p_start_state;
272 if (composite(ruletype) || context_restriction(ruletype))
277 build_wfst(end_LC,end_RP,rulepair);
279 build_wfst(end_RP,p_start_state,rightcontext);
281 for (i=end_RP; i < err_state; i++)
288 for (p=fp; p !=
NIL; p=
cdr(p))
290 build_wfst(i,err_state,
car(p));
291 build_wfst(i,p_start_state,epsilon_label());
296 build_wfst(end_LC,p_start_state,rulepair);
300 if (composite(ruletype) || surface_coercion(ruletype))
302 LISP abrp = all_but(rulepair,fp);
309 build_wfst(end_LC,end_NOTRP,abrp);
311 build_wfst(end_NOTRP,end_RC,rightcontext);
314 for (i=end_NOTRP; i < p_num_states; i++)
316 build_wfst(i,p_start_state,epsilon_label());
323 build_wfst(end_LC,end_RC,abrp);
329 static LISP all_but(LISP rulepair,LISP
fp)
348 for (r=fp; r !=
NIL; r =
cdr(r))
361 if ((l != lr) && (s == sr))
void minimize(const EST_WFST &a)
Build minimized form of a.
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
a call representing a weighted finite-state transducer
A Regular expression class to go with the CSTR EST_String class.
#define Instantiate_TList(TYPE)
int siod_llength(LISP list)
const T & last() const
return const reference to last item in list
LISP strintern(const char *data)
LISP append(LISP l1, LISP l2)
void intersect(wfst_list &wl, EST_WFST &all)
void intersection(EST_TList< EST_WFST > &wl)
LISP siod_assoc_str(const char *key, LISP alist)
void determinize(const EST_WFST &a)
Build determinized form of a.
Declare_TList(EST_WFST) static LISP expand_fp(const EST_String p
LISP siod_nth(int nth, LISP list)
const char * get_c_string(LISP x)
LISP cons(LISP x, LISP y)
void kkcompile(LISP ruleset, EST_WFST &all_wfst)
void kkrule_compile(LISP inalpha, LISP outalpha, LISP fp, LISP rule, LISP sets)
const T & first() const
return const reference to first item in list
int matches(const char *e, ssize_t pos=0) const
Exactly match this string?
void append(const T &item)
add item onto end of list
LISP rintern(const char *name)
ostream & operator<<(ostream &s, const EST_WFST &w)
EST_String summary() const
EST_String after(int pos, int len=1) const
Part after pos+len.
EST_String before(int pos, int len=0) const
Part before position.
void reverse(EST_Wave &sig)
LISP siod_member_str(const char *key, LISP list)
EST_Litem * remove(EST_Litem *ptr)