2017-03-18 17:14:48 +03:00
|
|
|
# coding: utf8
|
2017-03-18 20:14:03 +03:00
|
|
|
from __future__ import print_function
|
2018-11-30 22:16:14 +03:00
|
|
|
|
2017-03-18 20:14:03 +03:00
|
|
|
# NB! This breaks in plac on Python 2!!
|
2017-10-27 15:39:51 +03:00
|
|
|
# from __future__ import unicode_literals
|
2017-03-18 17:14:48 +03:00
|
|
|
|
2018-11-30 22:16:14 +03:00
|
|
|
if __name__ == "__main__":
|
2017-03-18 17:14:48 +03:00
|
|
|
import plac
|
|
|
|
import sys
|
2018-11-30 22:16:14 +03:00
|
|
|
from wasabi import Printer
|
2018-11-16 00:17:16 +03:00
|
|
|
from spacy.cli import download, link, info, package, train, pretrain, convert
|
2018-11-30 22:16:14 +03: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 13:28:58 +03:00
|
|
|
|
2017-08-19 22:45:23 +03:00
|
|
|
commands = {
|
2018-11-30 22:16:14 +03: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 22:45:23 +03:00
|
|
|
}
|
2017-05-22 12:46:45 +03:00
|
|
|
if len(sys.argv) == 1:
|
2018-11-30 22:16:14 +03:00
|
|
|
msg.info("Available commands", ", ".join(commands), exits=1)
|
2017-05-22 12:46:45 +03:00
|
|
|
command = sys.argv.pop(1)
|
2018-11-30 22:16:14 +03:00
|
|
|
sys.argv[0] = "spacy %s" % command
|
2017-05-22 12:46:45 +03:00
|
|
|
if command in commands:
|
2018-01-04 23:33:47 +03:00
|
|
|
plac.call(commands[command], sys.argv[1:])
|
2017-05-22 12:46:45 +03:00
|
|
|
else:
|
2018-11-30 22:16:14 +03:00
|
|
|
available = "Available: {}".format(", ".join(commands))
|
|
|
|
msg.fail("Unknown command: {}".format(command), available, exits=1)
|