mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 01:16:28 +03:00
Add function to resolve load name
Warn if old 'path' keyword argument is used.
This commit is contained in:
parent
e6f1a5d0a1
commit
b9ba58ba5c
|
@ -10,8 +10,7 @@ from . import util
|
|||
|
||||
|
||||
def load(name, **overrides):
|
||||
if overrides.get('path') not in (None, False, True):
|
||||
name = overrides.get('path')
|
||||
name = util.resolve_load_name(name, **overrides)
|
||||
model_path = util.resolve_model_path(name)
|
||||
meta = util.parse_package_meta(model_path)
|
||||
if 'lang' not in meta:
|
||||
|
|
|
@ -142,6 +142,15 @@ def read_json(location):
|
|||
return ujson.load(f)
|
||||
|
||||
|
||||
def resolve_load_name(name, **overrides):
|
||||
if overrides.get('path') not in (None, False, True):
|
||||
name = overrides.get('path')
|
||||
prints("To load a model from a path, you can now use the first argument.",
|
||||
"OLD: spacy.load('en', path='/some/path')", "NEW: spacy.load('/some/path')",
|
||||
title="Warning: deprecated argument 'path'")
|
||||
return name
|
||||
|
||||
|
||||
def resolve_model_path(name):
|
||||
data_path = get_data_path()
|
||||
if not data_path or not data_path.exists():
|
||||
|
|
Loading…
Reference in New Issue
Block a user