60static int wfst_build_main(
int argc,
char **
argv);
127static int wfst_build_main(
int argc,
char **
argv)
136 EST_String(
"[option] [rulefile0] [rulefile1] ...\n")+
137 "Summary: Build a weighted finite state transducer from rules/wfsts\n"+
138 "-type <string> {kk} Input rule type: kk, lts, rg, tl, compose, regex\n"+
139 " union, intersect, concat, asis\n"+
140 "-determinize Determinize WFST before saving it\n"+
141 "-detmin Determinize and minimize WFST before saving it\n"+
142 "-o <ofile> Output file for saved WFST (default stdout)\n"+
143 "-otype <string> {ascii}\n"+
144 " Output type, ascii or binary\n"+
145 "-heap <int> {210000}\n"+
146 " Set size of Lisp heap, needed for large rulesets\n"+
147 "-q Quiet mode, no summary generated\n",
150 if (
al.present(
"-o"))
151 outfile =
al.val(
"-o");
155 siod_init(
al.ival(
"-heap"));
162 if (
al.val(
"-type") ==
"kk")
167 else if (
al.val(
"-type") ==
"lts")
172 else if (
al.val(
"-type") ==
"rg")
177 else if (
al.val(
"-type") ==
"tl")
182 else if (
al.val(
"-type") ==
"asis")
186 else if (
al.val(
"-type") ==
"compose")
190 if (
files.length() != 2)
191 EST_error(
"compose requires two WFSTs to combine");
198 else if (
al.val(
"-type") ==
"union")
202 if (
files.length() != 2)
203 EST_error(
"union requires two WFSTs to combine");
210 else if (
al.val(
"-type") ==
"intersect")
214 if (
files.length() != 2)
215 EST_error(
"intersect requires two WFSTs to combine");
221 else if (
al.val(
"-type") ==
"concat")
225 if (
files.length() != 2)
226 EST_error(
"concat requires two WFSTs to combine");
232 else if (
al.val(
"-type") ==
"difference")
236 if (
files.length() != 2)
237 EST_error(
"difference requires two WFSTs to combine");
243 else if (
al.val(
"-type") ==
"regex")
252 cerr <<
"wfst_build: unknown rule type \"" <<
al.val(
"-type")
257 if (
al.present(
"-determinize"))
260 dwfst->determinize(*wfst);
261 if (!
al.present(
"-q"))
263 cout <<
"wfst_build summary: " <<
endl;
264 cout <<
" non-deterministic wfst: " <<
265 wfst->summary() <<
endl;
266 cout <<
" deterministic wfst: " <<
272 else if (
al.present(
"-detmin"))
274 if (!
al.present(
"-q"))
276 cout <<
"wfst_build summary: " <<
endl;
277 cout <<
" non-deterministic wfst: " <<
278 wfst->summary() <<
endl;
281 dwfst->determinize(*wfst);
283 if (!
al.present(
"-q"))
284 cout <<
" deterministic wfst: " <<
288 if (!
al.present(
"-q"))
289 cout <<
" minimized wfst: " <<
296 if (!
al.present(
"-q"))
297 cout <<
"wfst_build: " << wfst->summary() <<
endl;
300 wfst->
save(outfile,
al.val(
"-otype"));
void difference(const EST_WFST &a, const EST_WFST &b)
void uunion(EST_TList< EST_WFST > &wl)
void compose(const EST_WFST &a, const EST_WFST &b)
EST_write_status save(const EST_String &filename, const EST_String type="ascii")
?
void concat(const EST_WFST &a, const EST_WFST &b)
void intersection(EST_TList< EST_WFST > &wl)
EST_read_status load(const EST_String &filename)
?