From ff690f76bae418296d56114c0c4c5a5bf3c31b0d Mon Sep 17 00:00:00 2001 From: Henning Peters Date: Tue, 12 Apr 2016 16:00:56 +0200 Subject: [PATCH] fix loading non-german models --- spacy/about.py | 1 - spacy/language.py | 3 ++- spacy/util.py | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/spacy/about.py b/spacy/about.py index 6abcb5d94..dd74e5d8c 100644 --- a/spacy/about.py +++ b/spacy/about.py @@ -14,4 +14,3 @@ __models__ = { 'en': 'en>=1.1.0,<1.2.0', 'de': 'de>=1.0.0,<1.1.0', } -__default_lang__ = 'en' diff --git a/spacy/language.py b/spacy/language.py index f186c2f2b..302e2ba76 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -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) diff --git a/spacy/util.py b/spacy/util.py index b1e93d08b..8032cf6fd 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -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 "