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