fix loading non-german models

This commit is contained in:
Henning Peters 2016-04-12 16:00:56 +02:00
parent 6215272786
commit ff690f76ba
3 changed files with 6 additions and 5 deletions

View File

@ -14,4 +14,3 @@ __models__ = {
'en': 'en>=1.1.0,<1.2.0',
'de': 'de>=1.0.0,<1.1.0',
}
__default_lang__ = 'en'

View File

@ -20,6 +20,7 @@ from .syntax.ner import BiluoPushDown
from .syntax.arc_eager import ArcEager
from . import util
from . import about
from .attrs import TAG, DEP, ENT_IOB, ENT_TYPE, HEAD
@ -167,7 +168,7 @@ class Language(object):
if package is None:
if data_dir is None:
package = util.get_package_by_name()
package = util.get_package_by_name(about.__models__[self.lang])
else:
package = util.get_package(data_dir)

View File

@ -36,11 +36,12 @@ def get_package(data_dir):
def get_package_by_name(name=None, via=None):
package_name = name or about.__models__[about.__default_lang__]
lang = get_lang_class(package_name)
if name is None:
return
lang = get_lang_class(name)
try:
return sputnik.package(about.__title__, about.__version__,
package_name, data_path=via)
name, data_path=via)
except PackageNotFoundException as e:
raise RuntimeError("Model '%s' not installed. Please run 'python -m "
"%s.download' to install latest compatible "