From 6b7f7a2060c4500d3c820712c4eac2daa5324880 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 26 Mar 2017 07:24:07 -0500 Subject: [PATCH] Connect parser L1 option to train CLI --- spacy/__main__.py | 5 ++++- spacy/cli/train.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spacy/__main__.py b/spacy/__main__.py index 4c702feca..3333e90a9 100644 --- a/spacy/__main__.py +++ b/spacy/__main__.py @@ -82,16 +82,19 @@ class CLI(object): train_data=("training data", "positional", None, str), dev_data=("development data", "positional", None, str), n_iter=("number of iterations", "option", "n", int), + parser_L1=("L1 regularization penalty for parser", "option", "L", float), no_tagger=("Don't train tagger", "flag", "T", bool), no_parser=("Don't train parser", "flag", "P", bool), no_ner=("Don't train NER", "flag", "N", bool) ) def train(self, lang, output_dir, train_data, dev_data, n_iter=15, + parser_L1=0.0, no_tagger=False, no_parser=False, no_ner=False): """Train a model.""" cli_train(lang, output_dir, train_data, dev_data, n_iter, - not no_tagger, not no_parser, not no_ner) + not no_tagger, not no_parser, not no_ner, + parser_L1) @plac.annotations( diff --git a/spacy/cli/train.py b/spacy/cli/train.py index 4cad4ec58..36f1d75a3 100644 --- a/spacy/cli/train.py +++ b/spacy/cli/train.py @@ -13,7 +13,8 @@ from ..gold import read_json_file as read_gold_json from .. import util -def train(language, output_dir, train_data, dev_data, n_iter, tagger, parser, ner): +def train(language, output_dir, train_data, dev_data, n_iter, tagger, parser, ner, + parser_L1): output_path = Path(output_dir) train_path = Path(train_data) dev_path = Path(dev_data) @@ -22,6 +23,7 @@ def train(language, output_dir, train_data, dev_data, n_iter, tagger, parser, ne lang = util.get_lang_class(language) parser_cfg = { 'pseudoprojective': True, + 'L1': parser_L1, 'n_iter': n_iter, 'lang': language, 'features': lang.Defaults.parser_features}