mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
37c7c85a86
* Support nowrap setting in util.prints * Tidy up and fix whitespace * Simplify script and use read_jsonl helper * Add JSON schemas (see #2928) * Deprecate Doc.print_tree Will be replaced with Doc.to_json, which will produce a unified format * Add Doc.to_json() method (see #2928) Converts Doc objects to JSON using the same unified format as the training data. Method also supports serializing selected custom attributes in the doc._. space. * Remove outdated test * Add write_json and write_jsonl helpers * WIP: Update spacy train * Tidy up spacy train * WIP: Use wasabi for formatting * Add GoldParse helpers for JSON format * WIP: add debug-data command * Fix typo * Add missing import * Update wasabi pin * Add missing import * 💫 Refactor CLI (#2943) To be merged into #2932. ## Description - [x] refactor CLI To use [`wasabi`](https://github.com/ines/wasabi) - [x] use [`black`](https://github.com/ambv/black) for auto-formatting - [x] add `flake8` config - [x] move all messy UD-related scripts to `cli.ud` - [x] make converters function that take the opened file and return the converted data (instead of having them handle the IO) ### Types of change enhancement ## Checklist <!--- Before you submit the PR, go over this checklist and make sure you can tick off all the boxes. [] -> [x] --> - [x] I have submitted the spaCy Contributor Agreement. - [x] I ran the tests, and all new and existing tests passed. - [x] My changes don't require a change to the documentation, or if they do, I've added all required information. * Update wasabi pin * Delete old test * Update errors * Fix typo * Tidy up and format remaining code * Fix formatting * Improve formatting of messages * Auto-format remaining code * Add tok2vec stuff to spacy.train * Fix typo * Update wasabi pin * Fix path checks for when train() is called as function * Reformat and tidy up pretrain script * Update argument annotations * Raise error if model language doesn't match lang * Document new train command
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
# coding: utf8
|
|
from __future__ import print_function
|
|
|
|
# NB! This breaks in plac on Python 2!!
|
|
# from __future__ import unicode_literals
|
|
|
|
if __name__ == "__main__":
|
|
import plac
|
|
import sys
|
|
from wasabi import Printer
|
|
from spacy.cli import download, link, info, package, train, pretrain, convert
|
|
from spacy.cli import init_model, profile, evaluate, validate
|
|
from spacy.cli import ud_train, ud_evaluate, debug_data
|
|
|
|
msg = Printer()
|
|
|
|
commands = {
|
|
"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,
|
|
}
|
|
if len(sys.argv) == 1:
|
|
msg.info("Available commands", ", ".join(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:
|
|
available = "Available: {}".format(", ".join(commands))
|
|
msg.fail("Unknown command: {}".format(command), available, exits=1)
|