57 static int scfg_train_main(
int argc,
char **argv);
60 int main(
int argc,
char **argv)
63 scfg_train_main(argc,argv);
69 static int scfg_train_main(
int argc,
char **argv)
79 "Summary: Train a stochastic context free grammar from a (bracketed) corpus\n"+
80 "-grammar <ifile> Grammar file, one rule per line.\n"+
81 "-corpus <ifile> Corpus file, one bracketed sentence per line.\n"+
82 "-method <string> {inout}\n"+
83 " Method for training: inout.\n"+
84 "-passes <int> {50}\n"+
85 " Number of training passes.\n"+
86 "-startpass <int> {0}\n"+
87 " Starting at pass N.\n"+
88 "-spread <int> Spread training data over N passes.\n"+
89 "-checkpoint <int> Save grammar every N passes\n"+
90 "-heap <int> {210000}\n"+
91 " Set size of Lisp heap, needed for large corpora\n"+
92 "-o <ofile> Output file for trained grammar.\n",
96 outfile = al.
val(
"-o");
106 grammar.
load(al.
val(
"-grammar"));
110 cerr <<
"scfg_train: no grammar specified" << endl;
116 grammar.load_corpus(al.
val(
"-corpus"));
120 cerr <<
"scfg_train: no corpus specified" << endl;
125 spread = al.
ival(
"-spread");
129 if (al.
val(
"-method") ==
"inout")
133 checkpoint = al.
ival(
"-checkpoint");
135 grammar.train_inout(al.
ival(
"-passes"),
136 al.
ival(
"-startpass"),
141 cerr <<
"scfg_train: unknown training method \"" <<
142 al.
val(
"-method") <<
"\"" << endl;
146 if (grammar.save(outfile) !=
write_ok)
148 cerr <<
"scfg_train: failed to write grammar to \"" <<
149 outfile <<
"\"" << endl;
EST_read_status load(const EST_String &filename)
Load grammar from named file.
A class used to train (and test) SCFGs is an extension of EST_SCFG.
int ival(const EST_String &rkey, int m=1) const
int main(int argc, char **argv)
The file was written successfully.
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.
int siod_init(int heap_size=DEFAULT_HEAP_SIZE)
int parse_command_line(int argc, char *argv[], const EST_String &usage, EST_StrList &files, EST_Option &al, int make_stdio=1)