mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Move resolve_load_name to deprecated
This commit is contained in:
parent
0095d5322b
commit
824d09bb74
|
@ -6,11 +6,12 @@ import importlib
|
||||||
from .compat import basestring_
|
from .compat import basestring_
|
||||||
from .cli.info import info
|
from .cli.info import info
|
||||||
from .glossary import explain
|
from .glossary import explain
|
||||||
|
from .deprecated import resolve_load_name
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
|
|
||||||
def load(name, **overrides):
|
def load(name, **overrides):
|
||||||
name = util.resolve_load_name(name, **overrides)
|
name = resolve_load_name(name, **overrides)
|
||||||
model_path = util.resolve_model_path(name)
|
model_path = util.resolve_model_path(name)
|
||||||
meta = util.parse_package_meta(model_path)
|
meta = util.parse_package_meta(model_path)
|
||||||
if 'lang' not in meta:
|
if 'lang' not in meta:
|
||||||
|
|
|
@ -21,3 +21,13 @@ def depr_model_download(lang):
|
||||||
"Downloading default '%s' model now..." % lang,
|
"Downloading default '%s' model now..." % lang,
|
||||||
title="Warning: deprecated command")
|
title="Warning: deprecated command")
|
||||||
download(lang)
|
download(lang)
|
||||||
|
|
||||||
|
|
||||||
|
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. "
|
||||||
|
"The model meta is used to load the required Language class.",
|
||||||
|
"OLD: spacy.load('en', path='/some/path')", "NEW: spacy.load('/some/path')",
|
||||||
|
title="Warning: deprecated argument 'path'")
|
||||||
|
return name
|
||||||
|
|
|
@ -55,16 +55,6 @@ def ensure_path(path):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
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. "
|
|
||||||
"The model meta is used to load the required Language class.",
|
|
||||||
"OLD: spacy.load('en', path='/some/path')", "NEW: spacy.load('/some/path')",
|
|
||||||
title="Warning: deprecated argument 'path'")
|
|
||||||
return name
|
|
||||||
|
|
||||||
|
|
||||||
def resolve_model_path(name):
|
def resolve_model_path(name):
|
||||||
data_path = get_data_path()
|
data_path = get_data_path()
|
||||||
if not data_path or not data_path.exists():
|
if not data_path or not data_path.exists():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user