spaCy/spacy/__main__.py

41 lines
1.2 KiB
Python
Raw Normal View History

# coding: utf8
2017-03-18 20:14:03 +03:00
from __future__ import print_function
# NB! This breaks in plac on Python 2!!
2017-10-27 15:39:51 +03:00
# from __future__ import unicode_literals
if __name__ == '__main__':
import plac
import sys
from spacy.cli import download, link, info, package, train, pretrain, convert
from spacy.cli import vocab, init_model, profile, evaluate, validate
from spacy.cli import ud_train, ud_evaluate
from spacy.util import prints
2017-08-19 22:45:23 +03:00
commands = {
'download': download,
'link': link,
'info': info,
'train': train,
'pretrain': pretrain,
'ud-train': ud_train,
2017-10-01 22:04:32 +03:00
'evaluate': evaluate,
'ud-evaluate': ud_evaluate,
2017-08-19 22:45:23 +03:00
'convert': convert,
'package': package,
2017-10-30 20:38:41 +03:00
'vocab': vocab,
'init-model': init_model,
2017-08-22 00:23:05 +03:00
'profile': profile,
2017-10-12 21:05:06 +03:00
'validate': validate
2017-08-19 22:45:23 +03:00
}
if len(sys.argv) == 1:
prints(', '.join(commands), title="Available commands", exits=1)
command = sys.argv.pop(1)
sys.argv[0] = 'spacy %s' % command
if command in commands:
plac.call(commands[command], sys.argv[1:])
else:
2017-08-19 22:45:23 +03:00
prints(
"Available: %s" % ', '.join(commands),
title="Unknown command: %s" % command,
exits=1)