mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 05:37:03 +03:00
fix loading non-german models
This commit is contained in:
parent
6215272786
commit
ff690f76ba
|
@ -14,4 +14,3 @@ __models__ = {
|
||||||
'en': 'en>=1.1.0,<1.2.0',
|
'en': 'en>=1.1.0,<1.2.0',
|
||||||
'de': 'de>=1.0.0,<1.1.0',
|
'de': 'de>=1.0.0,<1.1.0',
|
||||||
}
|
}
|
||||||
__default_lang__ = 'en'
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ from .syntax.ner import BiluoPushDown
|
||||||
from .syntax.arc_eager import ArcEager
|
from .syntax.arc_eager import ArcEager
|
||||||
|
|
||||||
from . import util
|
from . import util
|
||||||
|
from . import about
|
||||||
from .attrs import TAG, DEP, ENT_IOB, ENT_TYPE, HEAD
|
from .attrs import TAG, DEP, ENT_IOB, ENT_TYPE, HEAD
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +168,7 @@ class Language(object):
|
||||||
|
|
||||||
if package is None:
|
if package is None:
|
||||||
if data_dir is None:
|
if data_dir is None:
|
||||||
package = util.get_package_by_name()
|
package = util.get_package_by_name(about.__models__[self.lang])
|
||||||
else:
|
else:
|
||||||
package = util.get_package(data_dir)
|
package = util.get_package(data_dir)
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,12 @@ def get_package(data_dir):
|
||||||
|
|
||||||
|
|
||||||
def get_package_by_name(name=None, via=None):
|
def get_package_by_name(name=None, via=None):
|
||||||
package_name = name or about.__models__[about.__default_lang__]
|
if name is None:
|
||||||
lang = get_lang_class(package_name)
|
return
|
||||||
|
lang = get_lang_class(name)
|
||||||
try:
|
try:
|
||||||
return sputnik.package(about.__title__, about.__version__,
|
return sputnik.package(about.__title__, about.__version__,
|
||||||
package_name, data_path=via)
|
name, data_path=via)
|
||||||
except PackageNotFoundException as e:
|
except PackageNotFoundException as e:
|
||||||
raise RuntimeError("Model '%s' not installed. Please run 'python -m "
|
raise RuntimeError("Model '%s' not installed. Please run 'python -m "
|
||||||
"%s.download' to install latest compatible "
|
"%s.download' to install latest compatible "
|
||||||
|
|
Loading…
Reference in New Issue
Block a user