From c90d4a6f17aa2940b744863c2491f23637fe0c24 Mon Sep 17 00:00:00 2001 From: Henning Peters Date: Sat, 26 Mar 2016 11:44:53 +0100 Subject: [PATCH] relative imports in __init__.py --- spacy/__init__.py | 12 ++++++------ spacy/util.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spacy/__init__.py b/spacy/__init__.py index d01bb11f3..676659fdd 100644 --- a/spacy/__init__.py +++ b/spacy/__init__.py @@ -1,15 +1,15 @@ -from . import util +from .util import set_lang_class, get_lang_class, get_package, get_package_by_name from .en import English from .de import German -util.register_lang(English.lang, English) -util.register_lang(German.lang, German) +set_lang_class(English.lang, English) +set_lang_class(German.lang, German) def load(name, vectors=None, via=None): - package = util.get_package_by_name(name, via=via) - vectors_package = util.get_package_by_name(vectors, via=via) - cls = util.get_lang(name) + package = get_package_by_name(name, via=via) + vectors_package = get_package_by_name(vectors, via=via) + cls = get_lang_class(name) return cls(package=package, vectors_package=vectors_package) diff --git a/spacy/util.py b/spacy/util.py index 4eda2d0e4..b1e93d08b 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -17,12 +17,12 @@ from .attrs import TAG, HEAD, DEP, ENT_IOB, ENT_TYPE LANGUAGES = {} -def register_lang(name, cls): +def set_lang_class(name, cls): global LANGUAGES LANGUAGES[name] = cls -def get_lang(name): +def get_lang_class(name): lang = re.split('[^a-zA-Z0-9_]', name, 1)[0] if lang not in LANGUAGES: raise RuntimeError('Language not supported: %s' % lang) @@ -37,7 +37,7 @@ 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(package_name) + lang = get_lang_class(package_name) try: return sputnik.package(about.__title__, about.__version__, package_name, data_path=via)