From e01fbacf8123ee265209f47db312818850ea8102 Mon Sep 17 00:00:00 2001 From: ines Date: Fri, 17 Mar 2017 19:26:28 +0100 Subject: [PATCH] Update resolve_model_name --- spacy/deprecated.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/spacy/deprecated.py b/spacy/deprecated.py index 2576c7f9a..30be24942 100644 --- a/spacy/deprecated.py +++ b/spacy/deprecated.py @@ -88,10 +88,11 @@ def fix_glove_vectors_loading(overrides): def resolve_model_name(name): - """If spaCy is loaded with 'en' or 'de', check if symlink already exists. If + """If spaCy is loaded with 'de', check if symlink already exists. If not, user have upgraded from older version and have old models installed. Check if old model directory exists and if so, return that instead and create - shortcut link. + shortcut link. If English model is found and no shortcut exists, raise error + and tell user to install new model. """ if name == 'en' or name == 'de': @@ -99,11 +100,19 @@ def resolve_model_name(name): data_path = Path(util.get_data_path()) model_path = data_path / name v_model_paths = [data_path / Path(name + '-' + v) for v in versions] - if not model_path.exists(): + + if not model_path.exists(): # no shortcut found for v_path in v_model_paths: - if v_path.exists(): - link(v_path, name) - return name + if v_path.exists(): # versioned model directory found + if name == 'de': + link(v_path, name) + return name + else: + raise ValueError( + "Found English model at {p}. This model is not " + "compatible with the current version. See " + "https://spacy.io/docs/usage/models to download the " + "new model.".format(p=v_path)) return name