2017-03-18 14:14:48 +00:00
|
|
|
# coding: utf8
|
2017-03-18 17:14:03 +00:00
|
|
|
from __future__ import print_function
|
2018-11-30 19:16:14 +00:00
|
|
|
|
2017-03-18 17:14:03 +00:00
|
|
|
# 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
|
|
|
|
2018-11-30 19:16:14 +00:00
|
|
|
if __name__ == "__main__":
|
2017-03-18 14:14:48 +00:00
|
|
|
import plac
|
|
|
|
import sys
|
2018-11-30 19:16:14 +00:00
|
|
|
from wasabi import Printer
|
2018-11-15 21:17:16 +00:00
|
|
|
from spacy.cli import download, link, info, package, train, pretrain, convert
|
2018-11-30 19:16:14 +00:00
|
|
|
from spacy.cli import init_model, profile, evaluate, validate
|
|
|
|
from spacy.cli import ud_train, ud_evaluate, debug_data
|
|
|
|
|
|
|
|
msg = Printer()
|
2017-05-22 10:28:58 +00:00
|
|
|
|
2017-08-19 19:45:23 +00:00
|
|
|
commands = {
|
2018-11-30 19:16:14 +00:00
|
|
|
"download": download,
|
|
|
|
"link": link,
|
|
|
|
"info": info,
|
|
|
|
"train": train,
|
|
|
|
"pretrain": pretrain,
|
|
|
|
"debug-data": debug_data,
|
|
|
|
"ud-train": ud_train,
|
|
|
|
"evaluate": evaluate,
|
|
|
|
"ud-evaluate": ud_evaluate,
|
|
|
|
"convert": convert,
|
|
|
|
"package": package,
|
|
|
|
"init-model": init_model,
|
|
|
|
"profile": profile,
|
|
|
|
"validate": validate,
|
2017-08-19 19:45:23 +00:00
|
|
|
}
|
2017-05-22 09:46:45 +00:00
|
|
|
if len(sys.argv) == 1:
|
2018-11-30 19:16:14 +00:00
|
|
|
msg.info("Available commands", ", ".join(commands), exits=1)
|
2017-05-22 09:46:45 +00:00
|
|
|
command = sys.argv.pop(1)
|
2018-11-30 19:16:14 +00:00
|
|
|
sys.argv[0] = "spacy %s" % command
|
2017-05-22 09:46:45 +00:00
|
|
|
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:
|
2018-11-30 19:16:14 +00:00
|
|
|
available = "Available: {}".format(", ".join(commands))
|
|
|
|
msg.fail("Unknown command: {}".format(command), available, exits=1)
|