62 static int wfst_build_main(
int argc,
char **argv);
65 int main(
int argc,
char **argv)
68 wfst_build_main(argc,argv);
74 static int wfst_build_main(
int argc,
char **argv)
83 EST_String(
"[option] [rulefile0] [rulefile1] ...\n")+
84 "Summary: Build a weighted finite state transducer from rules/wfsts\n"+
85 "-type <string> {kk} Input rule type: kk, lts, rg, tl, compose, regex\n"+
86 " union, intersect, concat, asis\n"+
87 "-determinize Determinize WFST before saving it\n"+
88 "-detmin Determinize and minimize WFST before saving it\n"+
89 "-o <ofile> Output file for saved WFST (default stdout)\n"+
90 "-otype <string> {ascii}\n"+
91 " Output type, ascii or binary\n"+
92 "-heap <int> {210000}\n"+
93 " Set size of Lisp heap, needed for large rulesets\n"+
94 "-q Quiet mode, no summary generated\n",
98 outfile = al.
val(
"-o");
105 LISP inalpha, outalpha;
109 if (al.
val(
"-type") ==
"kk")
114 else if (al.
val(
"-type") ==
"lts")
119 else if (al.
val(
"-type") ==
"rg")
124 else if (al.
val(
"-type") ==
"tl")
129 else if (al.
val(
"-type") ==
"asis")
133 else if (al.
val(
"-type") ==
"compose")
138 EST_error(
"compose requires two WFSTs to combine");
145 else if (al.
val(
"-type") ==
"union")
150 EST_error(
"union requires two WFSTs to combine");
157 else if (al.
val(
"-type") ==
"intersect")
162 EST_error(
"intersect requires two WFSTs to combine");
168 else if (al.
val(
"-type") ==
"concat")
173 EST_error(
"concat requires two WFSTs to combine");
179 else if (al.
val(
"-type") ==
"difference")
184 EST_error(
"difference requires two WFSTs to combine");
190 else if (al.
val(
"-type") ==
"regex")
199 cerr <<
"wfst_build: unknown rule type \"" << al.
val(
"-type")
204 if (al.
present(
"-determinize"))
210 cout <<
"wfst_build summary: " << endl;
211 cout <<
" non-deterministic wfst: " <<
213 cout <<
" deterministic wfst: " <<
219 else if (al.
present(
"-detmin"))
223 cout <<
"wfst_build summary: " << endl;
224 cout <<
" non-deterministic wfst: " <<
231 cout <<
" deterministic wfst: " <<
236 cout <<
" minimized wfst: " <<
244 cout <<
"wfst_build: " << wfst->
summary() << endl;
247 wfst->
save(outfile,al.
val(
"-otype"));
void minimize(const EST_WFST &a)
Build minimized form of a.
a call representing a weighted finite-state transducer
int ival(const EST_String &rkey, int m=1) const
void gc_unprotect(LISP *location)
void ltscompile(LISP lts_rules, EST_WFST &all_wfst)
int main(int argc, char **argv)
void intersection(EST_TList< EST_WFST > &wl)
T & nth(int n)
return the Nth value
void determinize(const EST_WFST &a)
Build determinized form of a.
LISP siod_nth(int nth, LISP list)
void tlcompile(LISP tl, EST_WFST &all_wfst)
LISP vload(const char *fname, long cflag)
void build_from_regex(LISP inalpha, LISP outalpha, LISP regex)
void kkcompile(LISP ruleset, EST_WFST &all_wfst)
void compose(const EST_WFST &a, const EST_WFST &b)
void rgcompile(LISP rg, EST_WFST &all_wfst)
EST_write_status save(const EST_String &filename, const EST_String type="ascii")
?
void concat(const EST_WFST &a, const EST_WFST &b)
void uunion(EST_TList< EST_WFST > &wl)
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
int present(const K &rkey) const
Returns true if key is present.
EST_String summary() const
void gc_protect(LISP *location)
int siod_init(int heap_size=DEFAULT_HEAP_SIZE)
void difference(const EST_WFST &a, const EST_WFST &b)
int parse_command_line(int argc, char *argv[], const EST_String &usage, EST_StrList &files, EST_Option &al, int make_stdio=1)
EST_read_status load(const EST_String &filename)
?