* Fix redundant options in train.py

This commit is contained in:
Matthew Honnibal 2015-07-17 22:38:05 +02:00
parent e29daea85f
commit a6ff7e6ca4

View File

@ -207,29 +207,22 @@ def write_parses(Language, dev_loc, model_dir, out_loc, beam_width=None):
out_loc=("Out location", "option", "o", str), out_loc=("Out location", "option", "o", str),
n_sents=("Number of training sentences", "option", "n", int), n_sents=("Number of training sentences", "option", "n", int),
n_iter=("Number of training iterations", "option", "i", int), n_iter=("Number of training iterations", "option", "i", int),
beam_width=("Number of candidates to maintain in the beam", "option", "k", int),
verbose=("Verbose error reporting", "flag", "v", bool), verbose=("Verbose error reporting", "flag", "v", bool),
debug=("Debug mode", "flag", "d", bool), debug=("Debug mode", "flag", "d", bool),
use_orig_arc_eager=("Use the original, monotonic arc-eager system", "flag", "m", bool)
) )
def main(train_loc, dev_loc, model_dir, n_sents=0, n_iter=15, out_loc="", verbose=False, def main(train_loc, dev_loc, model_dir, n_sents=0, n_iter=15, out_loc="", verbose=False,
debug=False, corruption_level=0.0, gold_preproc=False, beam_width=1, debug=False, corruption_level=0.0, gold_preproc=False, eval_only=False):
eval_only=False, use_orig_arc_eager=False):
if use_orig_arc_eager:
English.ParserTransitionSystem = TreeArcEager
if not eval_only: if not eval_only:
gold_train = list(read_json_file(train_loc)) gold_train = list(read_json_file(train_loc))
train(English, gold_train, model_dir, train(English, gold_train, model_dir,
feat_set='basic' if not debug else 'debug', feat_set='basic' if not debug else 'debug',
gold_preproc=gold_preproc, n_sents=n_sents, gold_preproc=gold_preproc, n_sents=n_sents,
corruption_level=corruption_level, n_iter=n_iter, corruption_level=corruption_level, n_iter=n_iter,
beam_width=beam_width, verbose=verbose, verbose=verbose)
use_orig_arc_eager=use_orig_arc_eager)
#if out_loc: #if out_loc:
# write_parses(English, dev_loc, model_dir, out_loc, beam_width=beam_width) # write_parses(English, dev_loc, model_dir, out_loc, beam_width=beam_width)
scorer = evaluate(English, list(read_json_file(dev_loc)), scorer = evaluate(English, list(read_json_file(dev_loc)),
model_dir, gold_preproc=gold_preproc, verbose=verbose, model_dir, gold_preproc=gold_preproc, verbose=verbose)
beam_width=beam_width)
print 'TOK', scorer.token_acc print 'TOK', scorer.token_acc
print 'POS', scorer.tags_acc print 'POS', scorer.tags_acc
print 'UAS', scorer.uas print 'UAS', scorer.uas