2017-03-18 17:14:48 +03:00
|
|
|
# coding: utf8
|
2017-03-18 20:14:03 +03:00
|
|
|
from __future__ import print_function
|
|
|
|
# NB! This breaks in plac on Python 2!!
|
2017-03-23 13:08:30 +03:00
|
|
|
#from __future__ import unicode_literals
|
2017-03-18 17:14:48 +03:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import plac
|
|
|
|
import sys
|
2017-05-22 13:28:58 +03:00
|
|
|
from spacy.cli import download, link, info, package, train, convert
|
|
|
|
from spacy.util import prints
|
|
|
|
|
|
|
|
commands = {'download': download, 'link': link, 'info': info, 'train': train,
|
|
|
|
'convert': convert, 'package': package}
|
2017-05-22 12:46:45 +03:00
|
|
|
if len(sys.argv) == 1:
|
2017-05-22 13:28:58 +03:00
|
|
|
prints(', '.join(commands), title="Available commands", exits=1)
|
2017-05-22 12:46:45 +03:00
|
|
|
command = sys.argv.pop(1)
|
|
|
|
sys.argv[0] = 'spacy %s' % command
|
|
|
|
if command in commands:
|
|
|
|
plac.call(commands[command])
|
|
|
|
else:
|
2017-05-22 13:28:58 +03:00
|
|
|
prints("Available: %s" % ', '.join(commands),
|
|
|
|
title="Unknown command: %s" % command, exits=1)
|