From d8d348bb5586a2053d6d6ff89801b144a5ca6360 Mon Sep 17 00:00:00 2001 From: Henning Peters Date: Fri, 18 Dec 2015 19:12:08 +0100 Subject: [PATCH] allow to specify version constraint within model name --- spacy/language.py | 11 +++-------- spacy/util.py | 9 ++------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/spacy/language.py b/spacy/language.py index cbbd942b5..2ea5eb162 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -167,15 +167,14 @@ class Language(object): 3) by a model name/version (and optionally a package root dir) - Language(model='en_default') - - Language(model='en_default', version='1.0.0') - - Language(model='en_default', version='1.0.0', data_dir='spacy/data') + - Language(model='en_default ==1.0.0') + - Language(model='en_default <1.1.0, data_dir='spacy/data') """ data_dir = kwargs.pop('data_dir', None) lang = kwargs.pop('lang', None) model = kwargs.pop('model', None) - version = kwargs.pop('version', None) vocab = kwargs.pop('vocab', None) tokenizer = kwargs.pop('tokenizer', None) @@ -210,11 +209,7 @@ class Language(object): warn("using non-package data_dir", DeprecationWarning) package = Package(data_dir) else: - if model is None: - model = '%s_default' % (lang or 'en') - version = None - package = get_package(name=model, version=version, - data_path=data_dir) + package = get_package(name=model, data_path=data_dir) if load_vectors is not True: warn("load_vectors is deprecated", DeprecationWarning) diff --git a/spacy/util.py b/spacy/util.py index be0b2f433..8c9ea319c 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -8,7 +8,7 @@ from sputnik import Sputnik from .attrs import TAG, HEAD, DEP, ENT_IOB, ENT_TYPE -def get_package(name=None, version=None, data_path=None): +def get_package(name=None, data_path=None): if data_path is None: if os.environ.get('SPACY_DATA'): data_path = os.environ.get('SPACY_DATA') @@ -18,12 +18,7 @@ def get_package(name=None, version=None, data_path=None): sputnik = Sputnik('spacy', '0.100.0') # TODO: retrieve version pool = sputnik.pool(data_path) - - if name is None: - name = 'en_default' - if version: - name += ' ==%s' % version - return pool.get(name) + return pool.get(name or 'en_default') def normalize_slice(length, start, stop, step=None):