Use plac annotations for arguments

This commit is contained in:
ines 2017-10-26 16:11:20 +02:00
parent c3b681e5fb
commit 4d896171ae

View File

@ -13,6 +13,7 @@ Last updated for: spaCy 2.0.0a18
"""
from __future__ import unicode_literals, print_function
import plac
import random
from pathlib import Path
@ -36,15 +37,12 @@ TRAIN_DATA = [
]
@plac.annotations(
model=("Model name. Defaults to blank 'en' model.", "option", "m", str),
output_dir=("Optional output directory", "option", "o", Path),
n_iter=("Number of training iterations", "option", "n", int))
def main(model=None, output_dir=None, n_iter=1000):
"""Load the model, set up the pipeline and train the parser.
model (unicode): Model name to start off with. If None, a blank English
Language class is created.
output_dir (unicode / Path): Optional output directory. If None, no model
will be saved.
n_iter (int): Number of iterations during training.
"""
"""Load the model, set up the pipeline and train the parser."""
if model is not None:
nlp = spacy.load(model) # load existing spaCy model
print("Loaded model '%s'" % model)
@ -100,7 +98,6 @@ def main(model=None, output_dir=None, n_iter=1000):
if __name__ == '__main__':
import plac
plac.call(main)
# expected result: