Don't pass CLI command name as dummy argument

This commit is contained in:
Søren Lind Kristiansen 2018-01-04 21:33:47 +01:00
parent 6a008233b5
commit 7f0ab145e9
12 changed files with 13 additions and 15 deletions

View File

@ -28,7 +28,7 @@ if __name__ == '__main__':
command = sys.argv.pop(1) command = sys.argv.pop(1)
sys.argv[0] = 'spacy %s' % command sys.argv[0] = 'spacy %s' % command
if command in commands: if command in commands:
plac.call(commands[command]) plac.call(commands[command], sys.argv[1:])
else: else:
prints( prints(
"Available: %s" % ', '.join(commands), "Available: %s" % ', '.join(commands),

View File

@ -24,8 +24,7 @@ CONVERTERS = {
n_sents=("Number of sentences per doc", "option", "n", int), n_sents=("Number of sentences per doc", "option", "n", int),
converter=("Name of converter (auto, iob, conllu or ner)", "option", "c", str), converter=("Name of converter (auto, iob, conllu or ner)", "option", "c", str),
morphology=("Enable appending morphology to tags", "flag", "m", bool)) morphology=("Enable appending morphology to tags", "flag", "m", bool))
def convert(_cmd, input_file, output_dir, n_sents=1, morphology=False, def convert(input_file, output_dir, n_sents=1, morphology=False, converter='auto'):
converter='auto'):
""" """
Convert files into JSON format for use with train command and other Convert files into JSON format for use with train command and other
experiment management functions. experiment management functions.

View File

@ -16,7 +16,7 @@ from .. import about
model=("model to download, shortcut or name)", "positional", None, str), model=("model to download, shortcut or name)", "positional", None, str),
direct=("force direct download. Needs model name with version and won't " direct=("force direct download. Needs model name with version and won't "
"perform compatibility check", "flag", "d", bool)) "perform compatibility check", "flag", "d", bool))
def download(_cmd, model, direct=False): def download(model, direct=False):
""" """
Download compatible model from default download path using pip. Model Download compatible model from default download path using pip. Model
can be shortcut, model name or, if --direct flag is set, full model name can be shortcut, model name or, if --direct flag is set, full model name

View File

@ -25,8 +25,8 @@ numpy.random.seed(0)
displacy_path=("directory to output rendered parses as HTML", "option", displacy_path=("directory to output rendered parses as HTML", "option",
"dp", str), "dp", str),
displacy_limit=("limit of parses to render as HTML", "option", "dl", int)) displacy_limit=("limit of parses to render as HTML", "option", "dl", int))
def evaluate(_cmd, model, data_path, gpu_id=-1, gold_preproc=False, def evaluate(model, data_path, gpu_id=-1, gold_preproc=False, displacy_path=None,
displacy_path=None, displacy_limit=25): displacy_limit=25):
""" """
Evaluate a model. To render a sample of parses in a HTML file, set an Evaluate a model. To render a sample of parses in a HTML file, set an
output directory as the displacy_path argument. output directory as the displacy_path argument.

View File

@ -13,7 +13,7 @@ from .. import util
@plac.annotations( @plac.annotations(
model=("optional: shortcut link of model", "positional", None, str), model=("optional: shortcut link of model", "positional", None, str),
markdown=("generate Markdown for GitHub issues", "flag", "md", str)) markdown=("generate Markdown for GitHub issues", "flag", "md", str))
def info(_cmd, model=None, markdown=False): def info(model=None, markdown=False):
"""Print info about spaCy installation. If a model shortcut link is """Print info about spaCy installation. If a model shortcut link is
speficied as an argument, print model information. Flag --markdown speficied as an argument, print model information. Flag --markdown
prints details in Markdown for easy copy-pasting to GitHub issues. prints details in Markdown for easy copy-pasting to GitHub issues.

View File

@ -25,7 +25,7 @@ from ..util import prints, ensure_path, get_lang_class
prune_vectors=("optional: number of vectors to prune to", prune_vectors=("optional: number of vectors to prune to",
"option", "V", int) "option", "V", int)
) )
def init_model(_cmd, lang, output_dir, freqs_loc, clusters_loc=None, vectors_loc=None, prune_vectors=-1): def init_model(lang, output_dir, freqs_loc, clusters_loc=None, vectors_loc=None, prune_vectors=-1):
""" """
Create a new model from raw data, like word frequencies, Brown clusters Create a new model from raw data, like word frequencies, Brown clusters
and word vectors. and word vectors.

View File

@ -13,7 +13,7 @@ from .. import util
origin=("package name or local path to model", "positional", None, str), origin=("package name or local path to model", "positional", None, str),
link_name=("name of shortuct link to create", "positional", None, str), link_name=("name of shortuct link to create", "positional", None, str),
force=("force overwriting of existing link", "flag", "f", bool)) force=("force overwriting of existing link", "flag", "f", bool))
def link(_cmd, origin, link_name, force=False, model_path=None): def link(origin, link_name, force=False, model_path=None):
""" """
Create a symlink for models within the spacy/data directory. Accepts Create a symlink for models within the spacy/data directory. Accepts
either the name of a pip package, or the local path to the model data either the name of a pip package, or the local path to the model data

View File

@ -20,7 +20,7 @@ from .. import about
"the command line prompt", "flag", "c", bool), "the command line prompt", "flag", "c", bool),
force=("force overwriting of existing model directory in output directory", force=("force overwriting of existing model directory in output directory",
"flag", "f", bool)) "flag", "f", bool))
def package(_cmd, input_dir, output_dir, meta_path=None, create_meta=False, def package(input_dir, output_dir, meta_path=None, create_meta=False,
force=False): force=False):
""" """
Generate Python package for model data, including meta and required Generate Python package for model data, including meta and required

View File

@ -29,7 +29,7 @@ def read_inputs(loc):
@plac.annotations( @plac.annotations(
lang=("model/language", "positional", None, str), lang=("model/language", "positional", None, str),
inputs=("Location of input file", "positional", None, read_inputs)) inputs=("Location of input file", "positional", None, read_inputs))
def profile(_cmd, lang, inputs=None): def profile(lang, inputs=None):
""" """
Profile a spaCy pipeline, to find out which functions take the most time. Profile a spaCy pipeline, to find out which functions take the most time.
""" """

View File

@ -38,7 +38,7 @@ numpy.random.seed(0)
version=("Model version", "option", "V", str), version=("Model version", "option", "V", str),
meta_path=("Optional path to meta.json. All relevant properties will be " meta_path=("Optional path to meta.json. All relevant properties will be "
"overwritten.", "option", "m", Path)) "overwritten.", "option", "m", Path))
def train(_cmd, lang, output_dir, train_data, dev_data, n_iter=30, n_sents=0, def train(lang, output_dir, train_data, dev_data, n_iter=30, n_sents=0,
use_gpu=-1, vectors=None, no_tagger=False, use_gpu=-1, vectors=None, no_tagger=False,
no_parser=False, no_entities=False, gold_preproc=False, no_parser=False, no_entities=False, gold_preproc=False,
version="0.0.0", meta_path=None): version="0.0.0", meta_path=None):

View File

@ -10,7 +10,7 @@ from ..util import prints, get_data_path, read_json
from .. import about from .. import about
def validate(_cmd): def validate():
"""Validate that the currently installed version of spaCy is compatible """Validate that the currently installed version of spaCy is compatible
with the installed models. Should be run after `pip install -U spacy`. with the installed models. Should be run after `pip install -U spacy`.
""" """

View File

@ -21,8 +21,7 @@ from ..util import prints, ensure_path
prune_vectors=("optional: number of vectors to prune to.", prune_vectors=("optional: number of vectors to prune to.",
"option", "V", int) "option", "V", int)
) )
def make_vocab(_cmd, lang, output_dir, lexemes_loc, def make_vocab(lang, output_dir, lexemes_loc, vectors_loc=None, prune_vectors=-1):
vectors_loc=None, prune_vectors=-1):
"""Compile a vocabulary from a lexicon jsonl file and word vectors.""" """Compile a vocabulary from a lexicon jsonl file and word vectors."""
if not lexemes_loc.exists(): if not lexemes_loc.exists():
prints(lexemes_loc, title="Can't find lexical data", exits=1) prints(lexemes_loc, title="Can't find lexical data", exits=1)