New Feature: display more detail when Error E067 (#2639)

* Fix off-by-one error

* Add verbose option

* Update verbose option

* Update documents for verbose option
This commit is contained in:
Xiaoquan Kong 2018-08-07 16:45:29 +08:00 committed by Matthew Honnibal
parent 1914c488d3
commit f0c9652ed1
3 changed files with 11 additions and 5 deletions

View File

@ -36,12 +36,13 @@ from ..compat import json_dumps
gold_preproc=("Use gold preprocessing", "flag", "G", bool),
version=("Model version", "option", "V", str),
meta_path=("Optional path to meta.json. All relevant properties will be "
"overwritten.", "option", "m", Path))
"overwritten.", "option", "m", Path),
verbose=("Display more information for debug", "option", None, bool))
def train(lang, output_dir, train_data, dev_data, n_iter=30, n_sents=0,
parser_multitasks='', entity_multitasks='',
use_gpu=-1, vectors=None, no_tagger=False,
no_parser=False, no_entities=False, gold_preproc=False,
version="0.0.0", meta_path=None):
version="0.0.0", meta_path=None, verbose=False):
"""
Train a model. Expects data in spaCy's JSON format.
"""
@ -143,7 +144,7 @@ def train(lang, output_dir, train_data, dev_data, n_iter=30, n_sents=0,
gold_preproc=gold_preproc))
nwords = sum(len(doc_gold[0]) for doc_gold in dev_docs)
start_time = timer()
scorer = nlp_loaded.evaluate(dev_docs)
scorer = nlp_loaded.evaluate(dev_docs, verbose)
end_time = timer()
if use_gpu < 0:
gpu_wps = None

View File

@ -30,7 +30,7 @@ def tags_to_entities(tags):
continue
elif tag.startswith('I'):
if start is None:
raise ValueError(Errors.E067.format(tags=tags[:i]))
raise ValueError(Errors.E067.format(tags=tags[:i+1]))
continue
if tag.startswith('U'):
entities.append((tag[2:], i, i))

View File

@ -260,7 +260,7 @@ p
+code(false, "bash", "$", false, false, true).
python -m spacy train [lang] [output_dir] [train_data] [dev_data] [--n-iter]
[--n-sents] [--use-gpu] [--meta-path] [--vectors] [--no-tagger] [--no-parser]
[--no-entities] [--gold-preproc]
[--no-entities] [--gold-preproc] [--verbose]
+table(["Argument", "Type", "Description"])
+row
@ -344,6 +344,11 @@ p
+cell flag
+cell Show help message and available arguments.
+row
+cell #[code --verbose]
+cell flag
+cell Show more detail message during training.
+row("foot")
+cell creates
+cell model, pickle