mirror of https://github.com/explosion/spaCy.git
Fix data loading on Python 2
This commit is contained in:
parent
baf36d0588
commit
ed95009b5c
|
@ -22,7 +22,7 @@ import ujson
|
|||
|
||||
from .symbols import ORTH
|
||||
from .compat import cupy, CudaStream, path2str, basestring_, input_, unicode_
|
||||
from .compat import copy_array, normalize_string_keys, getattr_
|
||||
from .compat import copy_array, normalize_string_keys, getattr_, import_file
|
||||
|
||||
|
||||
LANGUAGES = {}
|
||||
|
@ -112,15 +112,13 @@ def load_model(name, **overrides):
|
|||
|
||||
def load_model_from_link(name, **overrides):
|
||||
"""Load a model from a shortcut link, or directory in spaCy data path."""
|
||||
init_file = get_data_path() / name / '__init__.py'
|
||||
spec = importlib.util.spec_from_file_location(name, str(init_file))
|
||||
path = get_data_path() / name / '__init__.py'
|
||||
try:
|
||||
cls = importlib.util.module_from_spec(spec)
|
||||
cls = import_file(name, path)
|
||||
except AttributeError:
|
||||
raise IOError(
|
||||
"Cant' load '%s'. If you're using a shortcut link, make sure it "
|
||||
"points to a valid model package (not just a data directory)." % name)
|
||||
spec.loader.exec_module(cls)
|
||||
return cls.load(**overrides)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue