45#include "EST_simplestats.h"
48static int wfst_run_main(
int argc,
char **
argv);
91static int wfst_run_main(
int argc,
char **
argv)
106 EST_String(
"[WFSTFILE] [input file0] ... [-o output file]\n")+
107 "Summary: Recognize/transduce using a WFST on data\n"+
108 "-wfst <ifile> The WFST to use\n"+
109 "-transduce Transduce input to output (default)\n"+
110 "-recog Recognize input consists of pairs\n"+
111 "-cumulate_into <ofile>\n"+
112 " Cumulate transitions to give new weights\n"+
113 " save new WFST into ofile\n"+
114 "-itype <string> char or token\n"+
115 "-quiet No extraneous messages\n"+
116 "-perplexity Calculate perplexity on given data set\n"+
117 "-heap <int> {210000}\n"+
118 " Set size of Lisp heap, needed for large wfsts\n"+
119 "-o <ofile> Output file for transduced forms\n",
122 if (
al.present(
"-o"))
125 EST_error(
"can't open output file for writing \"%s\"",
126 (
const char *)
al.val(
"-o"));
131 if (
al.present(
"-wfst"))
134 EST_error(
"no WFST specified");
136 siod_init(
al.ival(
"-heap"));
142 EST_error(
"failed to read WFST from \"%s\"",
145 if (
al.present(
"-cumulate_into"))
148 for (f=
files.head(); f != 0; f=f->next())
154 EST_error(
"failed to read WFST data file from \"%s\"",
155 (
const char *)
files(f));
163 while((!
ts.eof()) && (!
ts.eoln()));
165 if (
al.present(
"-recog"))
167 if (
al.present(
"-perplexity"))
169 r = recognize_for_perplexity(wfst,
istrs,
170 al.present(
"-quiet"),
180 r = recognize(wfst,
istrs,
al.present(
"-quiet"));
193 if (!
al.present(
"-quiet"))
204 if (
al.present(
"-cumulate_into"))
207 if (wfst.
save(
al.val(
"-cumulate_into")) != write_ok)
208 EST_error(
"failed to write cumulated WFST to \"%s\"",
209 (
const char *)
al.val(
"-cumulate_into"));
212 printf(
"total %d OK %f%% failed %f%%\n",
213 (
int)
R.samples(),
R.mean()*100,(1-
R.mean())*100);
214 if (
al.present(
"-perplexity"))
216 printf(
"perplexity is %f\n",
pow(
float(2.0),
float(-1.0 * (
sumlogp/count))));
void start_cumulate()
Clear and start cumulation.
EST_write_status save(const EST_String &filename, const EST_String type="ascii")
?
void stop_cumulate()
Stop cumulation and calculate probabilities on transitions.
EST_read_status load(const EST_String &filename)
?